summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-03-06 19:01:18 +0000
committerSanjay Patel <spatel@rotateright.com>2018-03-06 19:01:18 +0000
commit1f2f5d18d3ca332a81c00e586f5e943ecdd16678 (patch)
tree1a5951ffeb036928b7b078828b4db16e9551ef85 /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
parent1c44e15f6d1fc2bcf4b2e0bf9014570ce42e3ff7 (diff)
downloadbcm5719-llvm-1f2f5d18d3ca332a81c00e586f5e943ecdd16678.tar.gz
bcm5719-llvm-1f2f5d18d3ca332a81c00e586f5e943ecdd16678.zip
[InstCombine] simplify min/max canonicalization; NFCI
llvm-svn: 326828
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 956b76c69e0..de1971ca542 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -713,23 +713,18 @@ canonicalizeMinMaxWithConstant(SelectInst &Sel, ICmpInst &Cmp,
// Canonicalize the compare predicate based on whether we have min or max.
Value *LHS, *RHS;
- ICmpInst::Predicate NewPred;
SelectPatternResult SPR = matchSelectPattern(&Sel, LHS, RHS);
- switch (SPR.Flavor) {
- case SPF_SMIN: NewPred = ICmpInst::ICMP_SLT; break;
- case SPF_UMIN: NewPred = ICmpInst::ICMP_ULT; break;
- case SPF_SMAX: NewPred = ICmpInst::ICMP_SGT; break;
- case SPF_UMAX: NewPred = ICmpInst::ICMP_UGT; break;
- default: return nullptr;
- }
+ if (!SelectPatternResult::isMinOrMax(SPR.Flavor))
+ return nullptr;
// Is this already canonical?
+ ICmpInst::Predicate CanonicalPred = getMinMaxPred(SPR.Flavor);
if (Cmp.getOperand(0) == LHS && Cmp.getOperand(1) == RHS &&
- Cmp.getPredicate() == NewPred)
+ Cmp.getPredicate() == CanonicalPred)
return nullptr;
// Create the canonical compare and plug it into the select.
- Sel.setCondition(Builder.CreateICmp(NewPred, LHS, RHS));
+ Sel.setCondition(Builder.CreateICmp(CanonicalPred, LHS, RHS));
// If the select operands did not change, we're done.
if (Sel.getTrueValue() == LHS && Sel.getFalseValue() == RHS)
OpenPOWER on IntegriCloud