Skip to content

Commit 11d8605

Browse files
[NVPTX] Add intrinsic range to nvvm_read_ptx_sreg_laneid
nvvm_read_ptx_sreg_laneid is used to represent the laneid of a thread running in a warp. Add a known range to the laneid intrinsic.
1 parent 4a13f09 commit 11d8605

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llvm/lib/Target/NVPTX/NVVMIntrRange.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ static bool runNVVMIntrRange(Function &F) {
130130
if (OverallClusterRank)
131131
return addRangeAttr(1, FunctionClusterRank + 1, II);
132132
break;
133+
134+
// Lane ID
135+
case Intrinsic::nvvm_read_ptx_sreg_laneid:
136+
return addRangeAttr(0, 32, II);
133137
default:
134138
return false;
135139
}

llvm/test/CodeGen/NVPTX/intr-range.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ define ptx_kernel i32 @test_cluster_dim() "nvvm.cluster_dim"="4,4,1" {
135135
ret i32 %11
136136
}
137137

138+
define ptx_kernel i32 @test_laneid() "nvvm.cluster_dim"="4,4,1" {
139+
; CHECK-LABEL: define ptx_kernel i32 @test_laneid(
140+
; CHECK-SAME: ) #[[ATTR4]] {
141+
; CHECK-NEXT: [[TMP1:%.*]] = call range(i32 0, 32) i32 @llvm.nvvm.read.ptx.sreg.laneid()
142+
; CHECK-NEXT: ret i32 [[TMP1]]
143+
;
144+
%1 = call i32 @llvm.nvvm.read.ptx.sreg.laneid()
145+
ret i32 %1
146+
}
147+
138148

139149
; DEFAULT-DAG: declare noundef range(i32 0, 1024) i32 @llvm.nvvm.read.ptx.sreg.tid.x()
140150
; DEFAULT-DAG: declare noundef range(i32 0, 1024) i32 @llvm.nvvm.read.ptx.sreg.tid.y()

0 commit comments

Comments
 (0)