[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
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 2f64c65..c47ebb3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -964,7 +964,7 @@
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 @@
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))