[llvm] [AMDGPU][InstCombine] Fold ballot intrinsic based on llvm.assume hints (PR #160670)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 12 20:10:21 PST 2025
================
@@ -1341,6 +1342,73 @@ 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
+ //
+ // Skip if Arg is not an instruction (e.g., constant, argument).
+ if (!isa<Instruction>(Arg))
+ break;
+
+ // Skip if ballot width < wave size (e.g., ballot.i32 on wave64).
+ if (ST->isWave64() && II.getType()->getIntegerBitWidth() == 32)
----------------
arsenm wrote:
```suggestion
if (WavefrontSize != II.getType()->getIntegerBitWidth())
```
https://github.com/llvm/llvm-project/pull/160670
More information about the llvm-commits
mailing list