[llvm] [AMDGPU][CodeGen] Do not rematerialize registers with convergent users (PR #222322)

Lucas Ramirez via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 06:17:04 PDT 2026


================
@@ -1593,6 +1593,15 @@ bool PreRARematStage::initGCNSchedStage() {
                [](const MachineInstr *DefMI) { return DefMI->isConvergent(); }))
       continue;
 
+    // A convergent user (e.g., V_READLANE*) may observe the definition's lanes
+    // whose contents depend on the EXEC mask in effect at the def. Moving the
+    // def into the use's region can change EXEC across the def and thus alter
+    // those lanes, so prevent rematerialization in that case.
+    if (any_of(Users, [](const MachineInstr *UserMI) {
----------------
lucas-rami wrote:

I added a check so that we check user convergence for divergent registers only, and allowed convergent users if they are in the same block as the original definition.

> but something also feels off about checking the users

Do you think it's a restriction that is too conservative?

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


More information about the llvm-commits mailing list