summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-07-26 17:34:28 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-07-26 17:34:28 +0000
commit41ba5c1455386c87c4b20aa7a1342e80261b7f79 (patch)
tree2b79275eae65eda6b8bcce8e87af4d42cd7b6174 /llvm/lib/CodeGen
parent223d921c6a17c037ba2d5276bc70e916df63827f (diff)
downloadbcm5719-llvm-41ba5c1455386c87c4b20aa7a1342e80261b7f79.tar.gz
bcm5719-llvm-41ba5c1455386c87c4b20aa7a1342e80261b7f79.zip
[DAGCombine] optimizeSetCCOfSignedTruncationCheck(): handle ule,ugt CondCodes.
Summary: A follow-up for D49266 / rL337166. At least one of these cases is more canonical, so we really do have to handle it. https://godbolt.org/g/pkzP3X https://rise4fun.com/Alive/pQyhZZ We won't get to these cases with I1 being -1, as that will be constant-folded to true or false. I'm also not sure we actually hit the 'ule' case, but i think the worst think that could happen is that being dead code. Reviewers: spatel, craig.topper, RKSimon, javed.absar, efriedma Reviewed By: spatel Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49497 llvm-svn: 338044
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 75d0a6bd58e..fa867fcec36 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1864,14 +1864,6 @@ SDValue TargetLowering::simplifySetCCWithAnd(EVT VT, SDValue N0, SDValue N1,
SDValue TargetLowering::optimizeSetCCOfSignedTruncationCheck(
EVT SCCVT, SDValue N0, SDValue N1, ISD::CondCode Cond, DAGCombinerInfo &DCI,
const SDLoc &DL) const {
- ISD::CondCode NewCond;
- if (Cond == ISD::CondCode::SETULT)
- NewCond = ISD::CondCode::SETEQ;
- else if (Cond == ISD::CondCode::SETUGE)
- NewCond = ISD::CondCode::SETNE;
- else
- return SDValue();
-
// We must be comparing with a constant.
ConstantSDNode *C1;
if (!(C1 = dyn_cast<ConstantSDNode>(N1)))
@@ -1891,7 +1883,24 @@ SDValue TargetLowering::optimizeSetCCOfSignedTruncationCheck(
// Validate constants ...
- const APInt &I1 = C1->getAPIntValue();
+ APInt I1 = C1->getAPIntValue();
+
+ ISD::CondCode NewCond;
+ if (Cond == ISD::CondCode::SETULT) {
+ NewCond = ISD::CondCode::SETEQ;
+ } else if (Cond == ISD::CondCode::SETULE) {
+ NewCond = ISD::CondCode::SETEQ;
+ // But need to 'canonicalize' the constant.
+ I1 += 1;
+ } else if (Cond == ISD::CondCode::SETUGT) {
+ NewCond = ISD::CondCode::SETNE;
+ // But need to 'canonicalize' the constant.
+ I1 += 1;
+ } else if (Cond == ISD::CondCode::SETUGE) {
+ NewCond = ISD::CondCode::SETNE;
+ } else
+ return SDValue();
+
const APInt &I01 = C01->getAPIntValue();
// Both of them must be power-of-two, and the constant from setcc is bigger.
if (!(I1.ugt(I01) && I1.isPowerOf2() && I01.isPowerOf2()))
OpenPOWER on IntegriCloud