[llvm] [SCEV] Collect guard info for ICMP NE w/o constants. (PR #160500)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 08:18:51 PDT 2025
================
@@ -15873,6 +15873,16 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
const SCEV *OneAlignedUp =
DividesBy ? GetNextSCEVDividesByDivisor(One, DividesBy) : One;
To = SE.getUMaxExpr(FromRewritten, OneAlignedUp);
+ } else {
+ if (LHS->getType()->isPointerTy()) {
+ LHS = SE.getLosslessPtrToIntExpr(LHS);
+ RHS = SE.getLosslessPtrToIntExpr(RHS);
+ if (isa<SCEVCouldNotCompute>(LHS) || isa<SCEVCouldNotCompute>(RHS))
+ break;
+ }
+ From = SE.getMinusSCEV(RHS, LHS);
----------------
nikic wrote:
Hm, wouldn't we have to add this for both RHS - LHS and LHS - RHS? Otherwise the guard will or will not work depending on whether you write RHS != LHS or LHS != RHS.
https://github.com/llvm/llvm-project/pull/160500
More information about the llvm-commits
mailing list