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

Momchil Velikov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 10:29:26 PST 2023


momchil-velikov wrote:

What would be the result of an input like:

```
C       I
  \    /
    P
```

i.e. we visit the PHI node `P` , which has two operands, one constant `C` and one instruction `I` that is not a PHI.

As far as I can tell, the first time around we will see `I` and return false from `CanConstantFoldPhi` so we exit immediately.

Next time we again return with false from `CanConstantFoldPhi` with `Const` set to `C` and `UnknownIncomingValues` empty.
We will not perform any iterations of the loop that calls `discoverStronglyConnectedComponent` (line 376).
We will not perform any iterations of the loop the calls `CanConstantFoldPhi` (line 380).
`CannotConstantFoldPhi` is initialised to `false`, so at the return at line 387 we will return `Const` which has a non-null value, 
set by the first call of `CanConstantFoldPhi` at line 364.

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


More information about the llvm-commits mailing list