[PATCH] D89739: [LCSSA] Doc for special treatment of PHIs

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 11:04:30 PDT 2020


Meinersbur added inline comments.


================
Comment at: llvm/docs/LoopTerminology.rst:463-464
+  can't be used from the PHI and onwards (otherwise the PHI would not
+  be needed in the first place). Effectively, the PHI kills the incoming
+  value(s) and replaces them with a new definition.
+
----------------
baziotis wrote:
> Meinersbur wrote:
> > Mmmh, more precisely, the dominance frontier will not allow uses of the value past it, unless it is passed on by a PHI node. Mem2Reg tries to minimize the number of PHIs, only adding them at dominance frontiers, but is not strictly required to (I am not sure whether the current implementation does). With LCSSA, we intentionally add PHIs even though we are not crossing a dominance frontier. 
> > 
> > I.e. it's not the PHI that kills a value and it is structurally valid (although optimizable) to use PHI as well as the incoming value as long as the dominance requirement is fulfilled. That is, both lifetimes may overlap (however if crossing a loop, that would obviously not be LCSSA normal form anymore).
> Yes, I totally agree! Yes formally one is allowed to re-use the value if it dominates the block, but if e.g. a human was hand-writing the
> code, they wouldn't probably use both values: Either they'd use the value because it dominates or they'd need to put a PHI (which 
> would kill in their head the previous value). Even if they put an artificial PHI for some reason (e.g. LCSSA), they would still probably
> not use the previous value, but instead the PHI.
> 
> Bottom-line, intuitively, the human would consider the value "live" and / or "used" up to the predecessor block, which is why IMHO this analogy is helpful for intuition.
> 
> That said, if you like the analogy, I still have to rewrite that somehow, on the one hand avoiding much formal details (because the goal of this is intuition) OTOH without writing incorrect things since this is now incorrect. How does that sound?
The analogy is ok, when made clear that this is not a strict requirement, but just a goal/intention/idealization.


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

https://reviews.llvm.org/D89739



More information about the llvm-commits mailing list