Skip to content

Commit dadea96

Browse files
authored
AMDGPU: Add range to wavefrontsize intrinsic declaration (#136303)
1 parent ada4ad9 commit dadea96

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ def int_amdgcn_init_exec_from_input : Intrinsic<[],
234234
def int_amdgcn_init_whole_wave : Intrinsic<[llvm_i1_ty], [], [
235235
IntrHasSideEffects, IntrNoMem, IntrConvergent]>;
236236

237-
def int_amdgcn_wavefrontsize :
238-
ClangBuiltin<"__builtin_amdgcn_wavefrontsize">,
239-
DefaultAttrsIntrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrSpeculatable]>;
237+
def int_amdgcn_wavefrontsize
238+
: ClangBuiltin<"__builtin_amdgcn_wavefrontsize">,
239+
DefaultAttrsIntrinsic<[llvm_i32_ty], [],
240+
[NoUndef<RetIndex>, Range<RetIndex, 32, 65>,
241+
IntrNoMem, IntrSpeculatable]>;
240242

241243
// Represent a relocation constant.
242244
def int_amdgcn_reloc_constant : DefaultAttrsIntrinsic<

llvm/test/Assembler/amdgcn-intrinsic-attributes.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ define i32 @ds_consume(ptr addrspace(3) %ptr) {
1818
ret i32 %ret
1919
}
2020

21+
; Test assumed range
22+
; CHECK: declare noundef range(i32 32, 65) i32 @llvm.amdgcn.wavefrontsize() #1
23+
define i32 @wavefrontsize() {
24+
%ret = call i32 @llvm.amdgcn.wavefrontsize()
25+
ret i32 %ret
26+
}
27+
2128
; CHECK: attributes #0 = { convergent nocallback nofree nounwind willreturn memory(argmem: readwrite) }
29+
; CHECK: attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

llvm/test/Transforms/InstCombine/AMDGPU/llvm.amdgcn.wavefrontsize.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ define amdgpu_kernel void @fold_and_optimize_wavefrontsize(ptr addrspace(1) noca
3939
; OPT-SAME: ptr addrspace(1) captures(none) [[ARG:%.*]]) {
4040
; OPT-NEXT: [[BB:.*:]]
4141
; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1]]
42-
; OPT-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[TMP]], 32
42+
; OPT-NEXT: [[TMP1:%.*]] = icmp samesign ugt i32 [[TMP]], 32
4343
; OPT-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 2, i32 1
4444
; OPT-NEXT: store i32 [[TMP2]], ptr addrspace(1) [[ARG]], align 4
4545
; OPT-NEXT: ret void
@@ -69,7 +69,7 @@ define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize(ptr addrspace(1) n
6969
; OPT-SAME: ptr addrspace(1) captures(none) [[ARG:%.*]]) {
7070
; OPT-NEXT: [[BB:.*:]]
7171
; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1]]
72-
; OPT-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[TMP]], 32
72+
; OPT-NEXT: [[TMP1:%.*]] = icmp samesign ugt i32 [[TMP]], 32
7373
; OPT-NEXT: br i1 [[TMP1]], label %[[BB2:.*]], label %[[BB3:.*]]
7474
; OPT: [[BB2]]:
7575
; OPT-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4

0 commit comments

Comments
 (0)