summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-06-02 18:03:05 +0000
committerSanjay Patel <spatel@rotateright.com>2016-06-02 18:03:05 +0000
commit5c0bc02878a6334f54af3be77e17354f13254778 (patch)
tree025540affe04812cac1c6f16cde3c6782f9ff5b9 /llvm
parentc932f533e1fed70c8b55a8fef979b9eaa81c38f3 (diff)
downloadbcm5719-llvm-5c0bc02878a6334f54af3be77e17354f13254778.tar.gz
bcm5719-llvm-5c0bc02878a6334f54af3be77e17354f13254778.zip
[InstCombine] remove guard for generating a vector select
This is effectively NFC because we already do this transform after r175380: http://reviews.llvm.org/rL175380 and also via foldBoolSextMaskToSelect(). This change should just make it a bit more efficient to match the pattern. The original guard was added in r95058: http://reviews.llvm.org/rL95058 A sampling of codegen for current in-tree targets shows no problems. This makes sense given that we're already producing the vector selects via the other transforms. llvm-svn: 271554
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index ea64910e445..c40d28f44aa 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1659,12 +1659,11 @@ Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) {
/// We have an expression of the form (A&C)|(B&D). Check if A is (cond?-1:0)
/// and either B or D is ~(cond?-1,0) or (cond?0,-1), then we can simplify this
/// expression to "cond ? C : D or B".
-static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
+static Instruction *matchSelectFromAndOr(Value *A, Value *B,
Value *C, Value *D) {
// If A is not a select of -1/0, this cannot match.
Value *Cond = nullptr;
- if (!match(A, m_SExt(m_Value(Cond))) ||
- !Cond->getType()->isIntegerTy(1))
+ if (!match(A, m_SExt(m_Value(Cond))) || !Cond->getType()->isIntegerTy(1))
return nullptr;
// ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
@@ -1678,6 +1677,7 @@ static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
return SelectInst::Create(Cond, C, D);
if (match(B, m_SExt(m_Not(m_Specific(Cond)))))
return SelectInst::Create(Cond, C, D);
+
return nullptr;
}
@@ -2274,18 +2274,14 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
}
// (A & (C0?-1:0)) | (B & ~(C0?-1:0)) -> C0 ? A : B, and commuted variants.
- // Don't do this for vector select idioms, the code generator doesn't handle
- // them well yet.
- if (!I.getType()->isVectorTy()) {
- if (Instruction *Match = MatchSelectFromAndOr(A, B, C, D))
- return Match;
- if (Instruction *Match = MatchSelectFromAndOr(B, A, D, C))
- return Match;
- if (Instruction *Match = MatchSelectFromAndOr(C, B, A, D))
- return Match;
- if (Instruction *Match = MatchSelectFromAndOr(D, A, B, C))
- return Match;
- }
+ if (Instruction *Match = matchSelectFromAndOr(A, B, C, D))
+ return Match;
+ if (Instruction *Match = matchSelectFromAndOr(B, A, D, C))
+ return Match;
+ if (Instruction *Match = matchSelectFromAndOr(C, B, A, D))
+ return Match;
+ if (Instruction *Match = matchSelectFromAndOr(D, A, B, C))
+ return Match;
// ((A&~B)|(~A&B)) -> A^B
if ((match(C, m_Not(m_Specific(D))) &&
OpenPOWER on IntegriCloud