Skip to content

Commit 9791e54

Browse files

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

clang/test/CodeGenOpenCL/builtins-amdgcn-wave32.cl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,23 @@ void test_ballot_wave32_target_attr(global uint* out, int a, int b)
2424
}
2525

2626
// CHECK-LABEL: @test_read_exec(
27-
// CHECK: call i32 @llvm.amdgcn.ballot.i32(i1 true)
27+
// CHECK: call i64 @llvm.amdgcn.ballot.i64(i1 true)
2828
void test_read_exec(global uint* out) {
2929
*out = __builtin_amdgcn_read_exec();
3030
}
3131

32+
// CHECK: declare i64 @llvm.amdgcn.ballot.i64(i1) #[[$NOUNWIND_READONLY:[0-9]+]]
33+
3234
// CHECK-LABEL: @test_read_exec_lo(
3335
// CHECK: call i32 @llvm.amdgcn.ballot.i32(i1 true)
3436
void test_read_exec_lo(global uint* out) {
3537
*out = __builtin_amdgcn_read_exec_lo();
3638
}
3739

3840
// CHECK-LABEL: @test_read_exec_hi(
39-
// CHECK: store i32 0, ptr addrspace(1) %out
41+
// CHECK: call i64 @llvm.amdgcn.ballot.i64(i1 true)
42+
// CHECK: lshr i64 [[A:%.*]], 32
43+
// CHECK: trunc i64 [[B:%.*]] to i32
4044
void test_read_exec_hi(global uint* out) {
4145
*out = __builtin_amdgcn_read_exec_hi();
4246
}

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ void AMDGPUDAGToDAGISel::SelectBRCOND(SDNode *N) {
23822382
auto CC = cast<CondCodeSDNode>(Cond->getOperand(2))->get();
23832383
if ((CC == ISD::SETEQ || CC == ISD::SETNE) &&
23842384
isNullConstant(Cond->getOperand(1)) &&
2385-
// We may encounter ballot.i64 in wave32 mode on -O0.
2385+
// TODO: make condition below an assert after fixing ballot bitwidth.
23862386
VCMP.getValueType().getSizeInBits() == ST->getWavefrontSize()) {
23872387
// %VCMP = i(WaveSize) AMDGPUISD::SETCC ...
23882388
// %C = i1 ISD::SETCC %VCMP, 0, setne/seteq

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -990,19 +990,6 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
990990
return IC.replaceInstUsesWith(II, Constant::getNullValue(II.getType()));
991991
}
992992
}
993-
if (ST->isWave32() && II.getType()->getIntegerBitWidth() == 64) {
994-
// %b64 = call i64 ballot.i64(...)
995-
// =>
996-
// %b32 = call i32 ballot.i32(...)
997-
// %b64 = zext i32 %b32 to i64
998-
Value *Call = IC.Builder.CreateZExt(
999-
IC.Builder.CreateIntrinsic(Intrinsic::amdgcn_ballot,
1000-
{IC.Builder.getInt32Ty()},
1001-
{II.getArgOperand(0)}),
1002-
II.getType());
1003-
Call->takeName(&II);
1004-
return IC.replaceInstUsesWith(II, Call);
1005-
}
1006993
break;
1007994
}
1008995
case Intrinsic::amdgcn_wqm_vote: {

llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,8 +2599,7 @@ declare i32 @llvm.amdgcn.ballot.i32(i1) nounwind readnone convergent
25992599

26002600
define i64 @ballot_nocombine_64(i1 %i) {
26012601
; CHECK-LABEL: @ballot_nocombine_64(
2602-
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.amdgcn.ballot.i32(i1 [[I:%.*]])
2603-
; CHECK-NEXT: [[B:%.*]] = zext i32 [[TMP1]] to i64
2602+
; CHECK-NEXT: [[B:%.*]] = call i64 @llvm.amdgcn.ballot.i64(i1 [[I:%.*]])
26042603
; CHECK-NEXT: ret i64 [[B]]
26052604
;
26062605
%b = call i64 @llvm.amdgcn.ballot.i64(i1 %i)
@@ -2617,8 +2616,7 @@ define i64 @ballot_zero_64() {
26172616

26182617
define i64 @ballot_one_64() {
26192618
; CHECK-LABEL: @ballot_one_64(
2620-
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.amdgcn.ballot.i32(i1 true)
2621-
; CHECK-NEXT: [[B:%.*]] = zext i32 [[TMP1]] to i64
2619+
; CHECK-NEXT: [[B:%.*]] = call i64 @llvm.amdgcn.ballot.i64(i1 true)
26222620
; CHECK-NEXT: ret i64 [[B]]
26232621
;
26242622
%b = call i64 @llvm.amdgcn.ballot.i64(i1 1)

0 commit comments

Comments
 (0)