[llvm] [AMDGPU][InstCombine] Fold ballot intrinsic based on llvm.assume hints (PR #160670)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 11 04:09:59 PST 2025


================
@@ -1341,6 +1342,71 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
       Call->takeName(&II);
       return IC.replaceInstUsesWith(II, Call);
     }
+
+    // Fold ballot intrinsic based on llvm.assume hint about the result.
+    //
+    // assume(ballot(x) == ballot(true)) -> x = true
+    // assume(ballot(x) == -1)           -> x = true
+    // assume(ballot(x) == 0)            -> x = false
----------------
jayfoad wrote:

We allow ballot.i32 in wave64 mode, which would break these optimizations.

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


More information about the llvm-commits mailing list