[PATCH] D104806: [ScalarEvolution] Make getMinusSCEV() fail for unrelated pointers.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 22:37:30 PDT 2021


efriedma added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:4096
+  if (RHS->getType()->isPointerTy()) {
+    if (!LHS->getType()->isPointerTy() ||
+        getPointerBase(LHS) != getPointerBase(RHS))
----------------
mkazantsev wrote:
> Should we fail by assertion if RHS is a pointer and LHS is not? I cannot figure a physical meaning of such situation.
The result almost certainly doesn't represent any value the program cares about, sure.  And probably no optimization would subtract a pointer from an integer intentionally.  Some of the code I'm patching just didn't consider whether a SCEV was pointer-typed, though; for example, isImpliedCondBalancedTypes() used getNotSCEV() on a pointer.

Maybe I'll leave adding an assertion for a followup, though?  I'm already sort of worried about this causing assertion failures in some codepath that isn't covered by the regression tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104806



More information about the llvm-commits mailing list