[PATCH] D152730: [ConstraintElim] Add A < B if A is an increasing phi for A != B.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 13:35:10 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp:1206
+  // in the loop.
+  unsigned StepSize = StepInst->getSourceElementType()->getScalarSizeInBits();
+  if (StepSize != 8) {
----------------
GEP steps by the type alloc size, which is generally not the same as the type size.


================
Comment at: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp:1210
+    if (!UpperGEP ||
+        StepSize != UpperGEP->getSourceElementType()->getScalarSizeInBits())
+      return;
----------------
I think you need significantly more checks to make this valid reasoning. There is no guarantee here that both GEPs are based on the same value, so maybe the induction GEP is going over 16 byte aligned pointers, while the UpperGEP is working on pointers offset by 8, in which case the condition will never be true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152730



More information about the llvm-commits mailing list