summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.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/InstCombineAndOrXor.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/InstCombineAndOrXor.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 2f4e97cb92a..44d11030eed 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1359,9 +1359,8 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
if (Instruction *Z = narrowMaskedBinOp(I))
return Z;
- if (isa<Constant>(Op1))
- if (Instruction *FoldedLogic = foldOpWithConstantIntoOperand(I))
- return FoldedLogic;
+ if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
+ return FoldedLogic;
if (Instruction *DeMorgan = matchDeMorgansLaws(I, Builder))
return DeMorgan;
@@ -1850,9 +1849,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
if (Value *V = SimplifyBSwap(I, Builder))
return replaceInstUsesWith(I, V);
- if (isa<Constant>(Op1))
- if (Instruction *FoldedLogic = foldOpWithConstantIntoOperand(I))
- return FoldedLogic;
+ if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
+ return FoldedLogic;
// Given an OR instruction, check to see if this is a bswap.
if (Instruction *BSwap = MatchBSwap(I))
@@ -2377,9 +2375,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
}
}
- if (isa<Constant>(Op1))
- if (Instruction *FoldedLogic = foldOpWithConstantIntoOperand(I))
- return FoldedLogic;
+ if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
+ return FoldedLogic;
{
Value *A, *B;
OpenPOWER on IntegriCloud