summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-02-28 16:36:24 +0000
committerSanjay Patel <spatel@rotateright.com>2018-02-28 16:36:24 +0000
commit8fdd87f9292cdd2419f3f10b3d8c12bcef5aee36 (patch)
treedafbee07e9bc079dbfa4edae6714340f5d91a7e1 /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
parent9de940b93bdbb0cf032b8337c5390630ba5e1acd (diff)
downloadbcm5719-llvm-8fdd87f9292cdd2419f3f10b3d8c12bcef5aee36.tar.gz
bcm5719-llvm-8fdd87f9292cdd2419f3f10b3d8c12bcef5aee36.zip
[InstCombine] move constant check into foldBinOpIntoSelectOrPhi; NFCI
Also, rename 'foldOpWithConstantIntoOperand' because that's annoyingly vague. The constant check is redundant in some cases, but it allows removing duplication for most of the calls. llvm-svn: 326329
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 2f64c655c08..c47ebb34087 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -964,7 +964,7 @@ Instruction *InstCombiner::foldAddWithConstant(BinaryOperator &Add) {
if (!match(Op1, m_Constant(Op1C)))
return nullptr;
- if (Instruction *NV = foldOpWithConstantIntoOperand(Add))
+ if (Instruction *NV = foldBinOpIntoSelectOrPhi(Add))
return NV;
Value *X;
@@ -1304,9 +1304,8 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- if (isa<Constant>(RHS))
- if (Instruction *FoldedFAdd = foldOpWithConstantIntoOperand(I))
- return FoldedFAdd;
+ if (Instruction *FoldedFAdd = foldBinOpIntoSelectOrPhi(I))
+ return FoldedFAdd;
// -A + B --> B - A
if (Value *LHSV = dyn_castFNegVal(LHS))
OpenPOWER on IntegriCloud