[all-commits] [llvm/llvm-project] b90a8d: [LoopInterchange] Add simplifyLCSSAPhis: remove ph...

Sjoerd Meijer via All-commits all-commits at lists.llvm.org
Mon Oct 20 02:23:57 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b90a8d385e0d35a2e870aa7b4cf16ee37df10851
      https://github.com/llvm/llvm-project/commit/b90a8d385e0d35a2e870aa7b4cf16ee37df10851
  Author: Sjoerd Meijer <smeijer at nvidia.com>
  Date:   2025-10-20 (Mon, 20 Oct 2025)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopInterchange.cpp
    A llvm/test/Transforms/LoopInterchange/lcssa-phi-outer-latch.ll

  Log Message:
  -----------
  [LoopInterchange] Add simplifyLCSSAPhis: remove phi from non-exit bb  (#160889)

This deals with a corner case of LCSSA phi nodes in the outer loop latch
block: the loop was in LCSSA form, some transformations can come along
(e.g. unswitch) and create an empty block:

     BB4:
       br label %BB5
     BB5:
       %old.cond.lcssa = phi i16 [ %cond, %BB4 ]
       br outer.header

Interchange then brings it in LCSSA form again and we get:

     BB4:
       %new.cond.lcssa = phi i16 [ %cond, %BB3 ]
       br label %BB5
     BB5:
       %old.cond.lcssa = phi i16 [ %new.cond.lcssa, %BB4 ]

Which means that we have a chain of LCSSA phi nodes from %new.cond.lcssa
to %old.cond.lcssa. The problem is that interchange can reoder blocks
BB4 and BB5 placing the use before the def if we don't check this. The
solution is to simplify lcssa phis, and remove them from non-exit blocks
if they are 1-input phi nodes.

Fixes #160068



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