[llvm] Add EliminateNewDuplicatePHINodes function. (PR #135179)

Valery Pykhtin via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 11 08:11:25 PDT 2025


vpykhtin wrote:

I agree that it's worth keeping a single implementation of PHI matching logic. There are several ways to improve it, as @LebedevRI outlined in https://reviews.llvm.org/D87408:

1. Matching PHIs with arbitrary order of incoming values.
2. Matching PHIs with undef incoming values.
3. Matching PHIs with incoming values from backedges.

We currently have two matching approaches:
- Hash-based matching
- `Instruction::isIdenticalToWhenDefined`

I'm not adding a new approach, just reusing existing functionality. However, I'm cautious about trying to fit all use cases into `EliminateDuplicatePHINodes`, as this would make it hard to keep them all in mind when introducing changes. 

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


More information about the llvm-commits mailing list