Skip to content

Commit 3711403

Browse files
committed
[AMDGPU] Mark mbcnt as convergent
since it depends on CFG. Otherwise some passes will try to merge them and cause incorrect results. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D145072
1 parent 010a979 commit 3711403

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,14 @@ kernel void test_gws_sema_p(uint id) {
676676

677677
// CHECK-LABEL: @test_mbcnt_lo(
678678
// CHECK: call i32 @llvm.amdgcn.mbcnt.lo(i32 %src0, i32 %src1)
679+
// CHECK: declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #[[$MBCNT_ATTRS:[0-9]+]]
679680
kernel void test_mbcnt_lo(global uint* out, uint src0, uint src1) {
680681
*out = __builtin_amdgcn_mbcnt_lo(src0, src1);
681682
}
682683

683684
// CHECK-LABEL: @test_mbcnt_hi(
684685
// CHECK: call i32 @llvm.amdgcn.mbcnt.hi(i32 %src0, i32 %src1)
686+
// CHECK: declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #[[$MBCNT_ATTRS]]
685687
kernel void test_mbcnt_hi(global uint* out, uint src0, uint src1) {
686688
*out = __builtin_amdgcn_mbcnt_hi(src0, src1);
687689
}
@@ -798,6 +800,7 @@ kernel void test_s_setreg(uint val) {
798800
// CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
799801
// CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { mustprogress nocallback nofree nosync nounwind willreturn memory(read) }
800802
// CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
803+
// CHECK-DAG: attributes #[[$MBCNT_ATTRS]] = {{.* convergent .*}}
801804
// CHECK-DAG: ![[$EXEC]] = !{!"exec"}
802805
// CHECK-DAG: ![[$EXEC_LO]] = !{!"exec_lo"}
803806
// CHECK-DAG: ![[$EXEC_HI]] = !{!"exec_hi"}

llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,12 +1570,12 @@ def int_amdgcn_live_mask : DefaultAttrsIntrinsic <[llvm_i1_ty],
15701570
def int_amdgcn_mbcnt_lo :
15711571
ClangBuiltin<"__builtin_amdgcn_mbcnt_lo">,
15721572
DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
1573-
[IntrNoMem]>;
1573+
[IntrNoMem, IntrConvergent]>;
15741574

15751575
def int_amdgcn_mbcnt_hi :
15761576
ClangBuiltin<"__builtin_amdgcn_mbcnt_hi">,
15771577
DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
1578-
[IntrNoMem]>;
1578+
[IntrNoMem, IntrConvergent]>;
15791579

15801580
// llvm.amdgcn.ds.swizzle src offset
15811581
def int_amdgcn_ds_swizzle :

0 commit comments

Comments
 (0)