[llvm] 4e4c89b - [EarlyCSE] Simplify max/min pattern matching. NFC.
Michael Liao via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 15:35:13 PDT 2020
Author: Michael Liao
Date: 2020-09-16T18:34:46-04:00
New Revision: 4e4c89b22c3fc1200ee0d6d1074173c7c53d87bc
URL: https://github.com/llvm/llvm-project/commit/4e4c89b22c3fc1200ee0d6d1074173c7c53d87bc
DIFF: https://github.com/llvm/llvm-project/commit/4e4c89b22c3fc1200ee0d6d1074173c7c53d87bc.diff
LOG: [EarlyCSE] Simplify max/min pattern matching. NFC.
Added:
Modified:
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index e47ecb4fbb44..86dd4d54d558 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -191,25 +191,16 @@ static bool matchSelectWithOptionalNotCond(Value *V, Value *&Cond, Value *&A,
Pred = ICmpInst::getSwappedPredicate(Pred);
}
- // Check for inverted variants of min/max by swapping operands.
- bool Inversed = false;
switch (Pred) {
- case CmpInst::ICMP_ULE:
- case CmpInst::ICMP_UGE:
- case CmpInst::ICMP_SLE:
- case CmpInst::ICMP_SGE:
- Pred = CmpInst::getInversePredicate(Pred);
- Inversed = true;
- break;
- default:
- break;
- }
-
- switch (Pred) {
- case CmpInst::ICMP_UGT: Flavor = Inversed ? SPF_UMIN : SPF_UMAX; break;
- case CmpInst::ICMP_ULT: Flavor = Inversed ? SPF_UMAX : SPF_UMIN; break;
- case CmpInst::ICMP_SGT: Flavor = Inversed ? SPF_SMIN : SPF_SMAX; break;
- case CmpInst::ICMP_SLT: Flavor = Inversed ? SPF_SMAX : SPF_SMIN; break;
+ case CmpInst::ICMP_UGT: Flavor = SPF_UMAX; break;
+ case CmpInst::ICMP_ULT: Flavor = SPF_UMIN; break;
+ case CmpInst::ICMP_SGT: Flavor = SPF_SMAX; break;
+ case CmpInst::ICMP_SLT: Flavor = SPF_SMIN; break;
+ // Non-strict inequalities.
+ case CmpInst::ICMP_ULE: Flavor = SPF_UMIN; break;
+ case CmpInst::ICMP_UGE: Flavor = SPF_UMAX; break;
+ case CmpInst::ICMP_SLE: Flavor = SPF_SMIN; break;
+ case CmpInst::ICMP_SGE: Flavor = SPF_SMAX; break;
default: break;
}
More information about the llvm-commits
mailing list