diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-06-24 20:36:34 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-06-24 20:36:34 +0000 |
commit | 2cbe6797745ddffc56cdcf50761b39c15a66c1e3 (patch) | |
tree | d9700d9b8b83897a6b5da1d6da556397af38902e /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 38238a4f56673f6b71e4776b108604118dd688e1 (diff) | |
download | llvm-2cbe6797745ddffc56cdcf50761b39c15a66c1e3.zip llvm-2cbe6797745ddffc56cdcf50761b39c15a66c1e3.tar.gz llvm-2cbe6797745ddffc56cdcf50761b39c15a66c1e3.tar.bz2 |
[InstCombine] use m_APInt; NFCI
llvm-svn: 273715
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index e23b70a..a02d8ea 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/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<OverflowingBinaryOperator>(&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<ConstantInt>(B); - ConstantInt *CC = dyn_cast<ConstantInt>(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; } |