[all-commits] [llvm/llvm-project] a314ac: [Reland][InstCombine] Iterative replacement in Ptr...

Anshil Gandhi via All-commits all-commits at lists.llvm.org
Mon Jun 23 17:36:01 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a314ac4d2299ed0ac2ab02c96be8e9fd2b6df8cf
      https://github.com/llvm/llvm-project/commit/a314ac4d2299ed0ac2ab02c96be8e9fd2b6df8cf
  Author: Anshil Gandhi <95053726+gandhi56 at users.noreply.github.com>
  Date:   2025-06-23 (Mon, 23 Jun 2025)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
    A llvm/test/Transforms/InstCombine/AMDGPU/ptr-replace-alloca.ll

  Log Message:
  -----------
  [Reland][InstCombine] Iterative replacement in PtrReplacer (#145410)

This patch enhances the PtrReplacer as follows:

1. Users are now collected iteratively to be generous on the stack. In
the case of PHIs with incoming values which have not yet been visited,
they are pushed back into the stack for reconsideration.
2. Replace users of the pointer root in a reverse-postorder traversal,
instead of a simple traversal over the collected users. This reordering
ensures that the uses of an instruction are replaced before replacing
the instruction itself.
3. During the replacement of PHI, use the same incoming value if it does
not have a replacement.

This patch specifically fixes the case when an incoming value of a PHI
is addrspacecasted.

This reland PR includes a fix for an assertion failure caused by
https://github.com/llvm/llvm-project/pull/137215, which was reverted.
The failing test involved a phi and gep depending on each other, in
which case the PtrReplacer did not order them correctly for replacement.
This patch fixes it by adding a check during the definition of
`PostOrderWorklist`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list