diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-01-10 23:49:07 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-01-10 23:49:07 +0000 |
commit | db0938fd9a53bb5ae432b15acda3c5b7082cf804 (patch) | |
tree | 0e2440b5e4ea6725496d72def57b0a22a9abbe5a /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | |
parent | 4f9d6d56c078a07f5020c6cbe8c55100184c27ff (diff) | |
download | bcm5719-llvm-db0938fd9a53bb5ae432b15acda3c5b7082cf804.tar.gz bcm5719-llvm-db0938fd9a53bb5ae432b15acda3c5b7082cf804.zip |
[InstCombine] add a wrapper for a common pair of transforms; NFCI
Some of the callers are artificially limiting this transform to integer types;
this should make it easier to incrementally remove that restriction.
llvm-svn: 291620
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 55151c13b43..2d34c1cc74b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1371,15 +1371,9 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) { SimplifyFAddInst(LHS, RHS, I.getFastMathFlags(), DL, &TLI, &DT, &AC)) return replaceInstUsesWith(I, V); - if (isa<Constant>(RHS)) { - if (isa<PHINode>(LHS)) - if (Instruction *NV = FoldOpIntoPhi(I)) - return NV; - - if (SelectInst *SI = dyn_cast<SelectInst>(LHS)) - if (Instruction *NV = FoldOpIntoSelect(I, SI)) - return NV; - } + if (isa<Constant>(RHS)) + if (Instruction *FoldedFAdd = foldOpWithConstantIntoOperand(I)) + return FoldedFAdd; // -A + B --> B - A // -A + -B --> -(A + B) |