3 Commits

Author SHA1 Message Date
pvanhout
7a5d850da2 [AMDGPU] Use UniformityAnalysis in RewriteUndefsForPHI
Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D145359
2023-03-06 12:15:33 +01:00
Ruiling Song
bf25a48985 Add override for runOnFunction()
Fix build-bot failure.
2022-09-26 10:19:35 +08:00
Ruiling Song
cf14c7caac AMDGPU: Add a pass to rewrite certain undef in PHI
For the pattern of IR (%if terminates with a divergent branch.),
divergence analysis will report %phi as uniform to help optimal code
generation.
```
  %if
  | \
  | %then
  | /
  %endif: %phi = phi [ %uniform, %if ], [ %undef, %then ]
```
In the backend, %phi and %uniform will be assigned a scalar register.
But the %undef from %then will make the scalar register dead in %then.
This will likely cause the register being over-written in %then. To fix
the issue, we will rewrite %undef as %uniform. For details, please refer
the comment in AMDGPURewriteUndefForPHI.cpp. Currently there is no test
changes shown, but this is mandatory for later changes.

Reviewed by: sameerds

Differential Revision: https://reviews.llvm.org/D133840
2022-09-26 09:54:47 +08:00