[AMDGPU] Handle multiple occurences of an incoming value in break large PHIs
authorpvanhout <pierre.vanhoutryve@amd.com>
Mon, 22 May 2023 09:15:15 +0000 (11:15 +0200)
committerpvanhout <pierre.vanhoutryve@amd.com>
Mon, 22 May 2023 11:40:26 +0000 (13:40 +0200)
commitfa87dd52d4327ad7313e924c1f27b9321fb253d2
tree007162523aafd6d78a6429c747761cac0897d58d
parent61346ed51fdab0314694f3dbbf6563bc2cc9cde2
[AMDGPU] Handle multiple occurences of an incoming value in break large PHIs

We naively broke all incoming values, assuming they'd be unique.
However it's not illegal to have multiple occurences of, e.g. `[BB0, V0]`
in a PHI node. What's illegal though is having the same basic block
multiple times but with different values, and it's exactly what the
transform caused. This broke in some rare applications where the pattern
arised.

Now we cache the `BasicBlock, Value` pairs we're breaking so we can reuse the values and preserve this invariant.

Solves SWDEV-399460

Reviewed By: #amdgpu, rovka

Differential Revision: https://reviews.llvm.org/D151069
llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-break-large-phis-heuristics.ll
llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-break-large-phis.ll