[PATCH] D123473: [LICM] Only create load in pre-header when promoting load.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 10:36:05 PDT 2022


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LICM.cpp:2177
+  }
+  SSA.AddAvailableValue(Preheader, InitialValue);
 
----------------
fhahn wrote:
> nikic wrote:
> > Do we need to add the poison value here at all? If we don't add it, shouldn't SSAUpdater avoid creating the phi altogether and directly use the value stored in the loop?
> We don't need to add the poison value. We still need the phi node in the test case, because the store doesn't dominate the exit. The SSA updater uses undef instead of poison.
Hm, it looks like adding the available value unconditionally was needed for the code later on to preserve LCSSA form. Otherwise SSAUpdater may introduce non-LCSSA uses later on.

I am planning on re-committing with a poison value for the pre-header to fix this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123473



More information about the llvm-commits mailing list