From 1fdd592ebcf5093ec329fec53bb4c884bb55340f Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 24 Jun 2016 20:36:34 +0000 Subject: [PATCH] [InstCombine] use m_APInt; NFCI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273715 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/InstructionCombining.cpp | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index e23b70ae6a8..a02d8ea396d 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -126,33 +126,23 @@ bool InstCombiner::ShouldChangeType(Type *From, Type *To) const { // all other opcodes, the function conservatively returns false. static bool MaintainNoSignedWrap(BinaryOperator &I, Value *B, Value *C) { OverflowingBinaryOperator *OBO = dyn_cast(&I); - if (!OBO || !OBO->hasNoSignedWrap()) { + if (!OBO || !OBO->hasNoSignedWrap()) return false; - } // We reason about Add and Sub Only. Instruction::BinaryOps Opcode = I.getOpcode(); - if (Opcode != Instruction::Add && - Opcode != Instruction::Sub) { + if (Opcode != Instruction::Add && Opcode != Instruction::Sub) return false; - } - ConstantInt *CB = dyn_cast(B); - ConstantInt *CC = dyn_cast(C); - - if (!CB || !CC) { + const APInt *BVal, *CVal; + if (!match(B, m_APInt(BVal)) || !match(C, m_APInt(CVal))) return false; - } - const APInt &BVal = CB->getValue(); - const APInt &CVal = CC->getValue(); bool Overflow = false; - - if (Opcode == Instruction::Add) { - BVal.sadd_ov(CVal, Overflow); - } else { - BVal.ssub_ov(CVal, Overflow); - } + if (Opcode == Instruction::Add) + BVal->sadd_ov(*CVal, Overflow); + else + BVal->ssub_ov(*CVal, Overflow); return !Overflow; } -- 2.50.1