summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-10-27 15:26:10 +0000
committerSanjay Patel <spatel@rotateright.com>2016-10-27 15:26:10 +0000
commite372aecb8ac914133c960bd8ea5c52c5fdebe81d (patch)
treebed2a0f595b58fba58b62ab9f3275cec63a59969 /llvm/lib
parent0eae9eccdf5dbd016fece11e03f564b8f1b1fbfb (diff)
downloadbcm5719-llvm-e372aecb8ac914133c960bd8ea5c52c5fdebe81d.tar.gz
bcm5719-llvm-e372aecb8ac914133c960bd8ea5c52c5fdebe81d.zip
[ValueTracking] fix matchSelectPattern to allow vector splat folds of min/max/abs/nabs
llvm-svn: 285303
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 84fece508a5..b99372a51fe 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3951,27 +3951,29 @@ static SelectPatternResult matchSelectPattern(CmpInst::Predicate Pred,
}
}
- if (ConstantInt *C1 = dyn_cast<ConstantInt>(CmpRHS)) {
+ const APInt *C1;
+ if (match(CmpRHS, m_APInt(C1))) {
if ((CmpLHS == TrueVal && match(FalseVal, m_Neg(m_Specific(CmpLHS)))) ||
(CmpLHS == FalseVal && match(TrueVal, m_Neg(m_Specific(CmpLHS))))) {
// ABS(X) ==> (X >s 0) ? X : -X and (X >s -1) ? X : -X
// NABS(X) ==> (X >s 0) ? -X : X and (X >s -1) ? -X : X
- if (Pred == ICmpInst::ICMP_SGT && (C1->isZero() || C1->isMinusOne())) {
+ if (Pred == ICmpInst::ICMP_SGT && (*C1 == 0 || C1->isAllOnesValue())) {
return {(CmpLHS == TrueVal) ? SPF_ABS : SPF_NABS, SPNB_NA, false};
}
// ABS(X) ==> (X <s 0) ? -X : X and (X <s 1) ? -X : X
// NABS(X) ==> (X <s 0) ? X : -X and (X <s 1) ? X : -X
- if (Pred == ICmpInst::ICMP_SLT && (C1->isZero() || C1->isOne())) {
+ if (Pred == ICmpInst::ICMP_SLT && (*C1 == 0 || *C1 == 1)) {
return {(CmpLHS == FalseVal) ? SPF_ABS : SPF_NABS, SPNB_NA, false};
}
}
// Y >s C ? ~Y : ~C == ~Y <s ~C ? ~Y : ~C = SMIN(~Y, ~C)
- if (const auto *C2 = dyn_cast<ConstantInt>(FalseVal)) {
- if (Pred == ICmpInst::ICMP_SGT && C1->getType() == C2->getType() &&
- ~C1->getValue() == C2->getValue() &&
+ const APInt *C2;
+ if (match(FalseVal, m_APInt(C2))) {
+ if (Pred == ICmpInst::ICMP_SGT &&
+ CmpRHS->getType() == FalseVal->getType() && ~(*C1) == *C2 &&
(match(TrueVal, m_Not(m_Specific(CmpLHS))) ||
match(CmpLHS, m_Not(m_Specific(TrueVal))))) {
LHS = TrueVal;
OpenPOWER on IntegriCloud