[PATCH] D133840: AMDGPU: Add a pass to rewrite certain undef in PHI

Ruiling, Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 22:25:58 PDT 2022


ruiling created this revision.
ruiling added reviewers: nhaehnle, foad, critson, sameerds.
Herald added subscribers: kosarev, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, mgorny, jvesely, kzhuravl, arsenm.
Herald added a project: All.
ruiling requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133840

Files:
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/CMakeLists.txt
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll
  llvm/test/CodeGen/AMDGPU/uniform-phi-with-undef.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133840.459986.patch
Type: text/x-patch
Size: 16032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220914/b48e414d/attachment.bin>


More information about the llvm-commits mailing list