[PATCH] D89456: [SCEV] Introduce SCEVPtrToIntExpr (PR46786)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 04:42:28 PDT 2020


lebedev.ri added a comment.

@mkazantsev thank you for taking a look!



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8483
+    if (Op == Cast->getOperand())
+      return Cast; // must be loop invariant
+    return getPtrToIntExpr(Op, Cast->getType());
----------------
mkazantsev wrote:
> It doesn't look like the right way to check for loop invariance. `getSCEVAtScope` can potentially simplify your expression that is still invariant. Example: you have `Op = A + B` and loop is guarded by condition `B = 0`. `getSCEVAtScope(Op)` may return `A` which is still loop invariant, but not equal to `Op`.
> 
> What you might be looking for is `isAvailableAtLoopEntry`.
Disclaimer: *i'm* not looking for loop invariance.
This chunk is a verbatum copy-paste from `SCEVTruncateExpr`/`SCEVSignExtendExpr`/`SCEVZeroExtendExpr` handling above.
If this isn't the right handling, then they are all wrong, and that's a preexisting problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89456/new/

https://reviews.llvm.org/D89456



More information about the llvm-commits mailing list