[PATCH] D144492: [InstCombine] Support multiple comparisons in foldAllocaCmp()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 20 10:51:12 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:925
+      // have other contributions from a select/phi operand.
+      // TODO: We could check whether getUnderlyingObjects() reduces to one
+      // object.
----------------
goldstein.w.n wrote:
> I don't understand this TODO, isn't `getUnderlyingObject(*U) == Alloca` doing just that?
getUnderlyingObject() does not look through phi nodes.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:956
+      eraseInstFromFunction(*ICmp);
+      Changed = true;
+      break;
----------------
goldstein.w.n wrote:
> Is there a reason this isn't in `InstructionSimplify`?
This can't be in InstSimplify because it is a correctness requirement that *all* comparisons of the alloca are replaced at the same time, something that InstSimplify cannot guarantee.


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

https://reviews.llvm.org/D144492



More information about the llvm-commits mailing list