[llvm] [FuncSpec] Update function specialization to handle phi-chains (PR #72903)

Momchil Velikov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 10:25:46 PST 2023


================
@@ -217,9 +217,23 @@ class InstCostVisitor : public InstVisitor<InstCostVisitor, Constant *> {
   Cost estimateSwitchInst(SwitchInst &I);
   Cost estimateBranchInst(BranchInst &I);
 
-  bool discoverTransitivelyIncomingValues(
-      Constant *Const, PHINode *Root, DenseSet<PHINode *> &TransitivePHIs,
-      SmallVectorImpl<PHINode *> &UnknownIncomingValues);
+  // Transitive Incoming Values are chains of PHI Nodes that
----------------
momchil-velikov wrote:

I suggest this comment instead:

> Transitively Incoming Values (TIV) is a set of Values that can "feed" a value to the initial PHI-node. It is defined like this:
>  * the initial PHI-node belongs to TIV
>  * for every PHI-node in TIV, its operands belong to TIV
> 
> If TIV for the initial PHI-node (P) contains more than one constant or a value that is not
> a PHI-node, then P cannot be folded to a constant. As soon as we detect these cases,
> we bail, without constructing the full TIV.
> Otherwise P can be folded to the one constant in TIV.
>

https://github.com/llvm/llvm-project/pull/72903


More information about the llvm-commits mailing list