[llvm] fc1f3e7 - Revert "Reland "[AMDGPU] Fix llvm.amdgcn.ballot with return width != wavefront size"" (#213713)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 3 10:49:32 PDT 2026
Author: Arseniy Obolenskiy
Date: 2026-08-03T17:49:27Z
New Revision: fc1f3e7a26f202a3928daa4102027e4c31746513
URL: https://github.com/llvm/llvm-project/commit/fc1f3e7a26f202a3928daa4102027e4c31746513
DIFF: https://github.com/llvm/llvm-project/commit/fc1f3e7a26f202a3928daa4102027e4c31746513.diff
LOG: Revert "Reland "[AMDGPU] Fix llvm.amdgcn.ballot with return width != wavefront size"" (#213713)
Reverts llvm/llvm-project#213635
buildbot failures are reported here:
https://github.com/llvm/llvm-project/pull/213635#issuecomment-5169081277
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Removed:
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ballot.i32.wave64.err.ll
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 0ddb7f771b6c9..22b8b10554928 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -1729,15 +1729,8 @@ bool AMDGPUInstructionSelector::selectBallot(MachineInstr &I) const {
const unsigned BallotSize = MRI->getType(DstReg).getSizeInBits();
const unsigned WaveSize = STI.getWavefrontSize();
- if (BallotSize < WaveSize) {
- const Function &Fn = MF->getFunction();
- Fn.getContext().diagnose(DiagnosticInfoUnsupported(
- Fn, "ballot return type is narrower than the wavefront size", DL));
- BuildMI(*BB, &I, DL, TII.get(AMDGPU::IMPLICIT_DEF), DstReg);
- I.eraseFromParent();
- return true;
- }
-
+ // In the common case, the return type matches the wave size.
+ // However we also support emitting i64 ballots in wave32 mode.
if (BallotSize != WaveSize && (BallotSize != 64 || WaveSize != 32))
return false;
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 40c662a89a4c4..612342b159583 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -7957,15 +7957,6 @@ static SDValue lowerBALLOTIntrinsic(const SITargetLowering &TLI, SDNode *N,
SDValue Src = N->getOperand(1);
SDLoc SL(N);
- unsigned WavefrontSize = TLI.getSubtarget()->getWavefrontSize();
- if (VT.getScalarSizeInBits() < WavefrontSize) {
- DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
- DAG.getMachineFunction().getFunction(),
- "ballot return type is narrower than the wavefront size",
- SL.getDebugLoc()));
- return DAG.getPOISON(VT);
- }
-
if (Src.getOpcode() == ISD::SETCC) {
SDValue Op0 = Src.getOperand(0);
SDValue Op1 = Src.getOperand(1);
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ballot.i32.wave64.err.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ballot.i32.wave64.err.ll
deleted file mode 100644
index 54400baf4affe..0000000000000
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.ballot.i32.wave64.err.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; RUN: not llc -global-isel=0 -mtriple=amdgpu9.00 -filetype=null %s 2>&1 | FileCheck %s
-; RUN: not llc -global-isel=1 -mtriple=amdgpu9.00 -filetype=null %s 2>&1 | FileCheck %s
-
-; An i32 ballot on a wave64 target cannot represent one bit per lane, so
-; both SelectionDAG and GlobalISel must refuse to lower it instead of
-; dropping the mask bits of the high lanes.
-
-declare i32 @llvm.amdgcn.ballot.i32(i1)
-
-; CHECK: error: {{.*}}ballot return type is narrower than the wavefront size
-define amdgpu_cs i32 @ballot_i32_wave64(i32 %x, i32 %y) {
- %cmp = icmp eq i32 %x, %y
- %ballot = call i32 @llvm.amdgcn.ballot.i32(i1 %cmp)
- ret i32 %ballot
-}
More information about the llvm-commits
mailing list