[llvm] [AMDGPU] Eliminate likely-spurious execz checks via intrinsic argument (PR #123749)

Fabian Ritter via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 05:44:24 PST 2025


================
@@ -281,7 +286,17 @@ void SILowerControlFlow::emitIf(MachineInstr &MI) {
   // Insert the S_CBRANCH_EXECZ instruction which will be optimized later
   // during SIPreEmitPeephole.
   MachineInstr *NewBr = BuildMI(MBB, I, DL, TII->get(AMDGPU::S_CBRANCH_EXECZ))
-                            .add(MI.getOperand(2));
+                            .add(MI.getOperand(3));
+
+  if (LikelyDivergent) {
+    MachineBasicBlock *ExeczDest = MI.getOperand(3).getMBB();
+    auto **E = MBB.succ_end();
+    for (auto **SI = MBB.succ_begin(); SI != E; ++SI) {
+      if (*SI == ExeczDest)
+        MBB.setSuccProbability(SI, BranchProbability::getZero());
+    }
+    MBB.normalizeSuccProbs();
----------------
ritter-x2a wrote:

Done in 9c90691f789a3159cf906e0554fea61f34abcfb0, thanks!

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


More information about the llvm-commits mailing list