diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-10-13 16:43:58 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-10-13 16:43:58 +0000 |
commit | 8d810fee436510db408fccb27a2c73076cf16536 (patch) | |
tree | dfb4d873f25548448db70ddf77d089f91ad5b1b4 /llvm/lib/Transforms | |
parent | 229a6d8d17478916ca3eabb7bb4c680761a14682 (diff) | |
download | bcm5719-llvm-8d810fee436510db408fccb27a2c73076cf16536.tar.gz bcm5719-llvm-8d810fee436510db408fccb27a2c73076cf16536.zip |
[InstCombine] rearrange code to remove repeated constant check; NFCI
llvm-svn: 315703
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineInternal.h | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index e12bff01376..75cc683b7a6 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -950,13 +950,15 @@ static Value *checkForNegativeOperand(BinaryOperator &I, return nullptr; } -static Instruction *foldAddWithConstant(BinaryOperator &Add, - InstCombiner::BuilderTy &Builder) { +Instruction *InstCombiner::foldAddWithConstant(BinaryOperator &Add) { Value *Op0 = Add.getOperand(0), *Op1 = Add.getOperand(1); Constant *Op1C; if (!match(Op1, m_Constant(Op1C))) return nullptr; + if (Instruction *NV = foldOpWithConstantIntoOperand(Add)) + return NV; + Value *X; Type *Ty = Add.getType(); if (match(Op0, m_ZExt(m_Value(X))) && @@ -1037,7 +1039,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { if (Value *V = SimplifyUsingDistributiveLaws(I)) return replaceInstUsesWith(I, V); - if (Instruction *X = foldAddWithConstant(I, Builder)) + if (Instruction *X = foldAddWithConstant(I)) return X; // FIXME: This should be moved into the above helper function to allow these @@ -1085,10 +1087,6 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { } } - if (isa<Constant>(RHS)) - if (Instruction *NV = foldOpWithConstantIntoOperand(I)) - return NV; - if (I.getType()->isIntOrIntVectorTy(1)) return BinaryOperator::CreateXor(LHS, RHS); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index f1404facaf3..88ce4de31df 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -663,6 +663,8 @@ private: /// This is a convenience wrapper function for the above two functions. Instruction *foldOpWithConstantIntoOperand(BinaryOperator &I); + Instruction *foldAddWithConstant(BinaryOperator &Add); + /// \brief Try to rotate an operation below a PHI node, using PHI nodes for /// its operands. Instruction *FoldPHIArgOpIntoPHI(PHINode &PN); |