Another SCEV issue from PR2607; essentially the same issue, but this
time applying to the implicit comparison in smin expressions. The
correct way to transform an inequality into the opposite
inequality, either signed or unsigned, is with a not expression.
I looked through the SCEV code, and I don't think there are any more
occurrences of this issue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54194 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 14c1389..bf6bc0b 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -1789,10 +1789,10 @@
if (LHS == U->getOperand(1) && RHS == U->getOperand(2))
return SE.getSMaxExpr(getSCEV(LHS), getSCEV(RHS));
else if (LHS == U->getOperand(2) && RHS == U->getOperand(1))
- // -smax(-x, -y) == smin(x, y).
- return SE.getNegativeSCEV(SE.getSMaxExpr(
- SE.getNegativeSCEV(getSCEV(LHS)),
- SE.getNegativeSCEV(getSCEV(RHS))));
+ // ~smax(~x, ~y) == smin(x, y).
+ return SE.getNotSCEV(SE.getSMaxExpr(
+ SE.getNotSCEV(getSCEV(LHS)),
+ SE.getNotSCEV(getSCEV(RHS))));
break;
case ICmpInst::ICMP_ULT:
case ICmpInst::ICMP_ULE: