Skip to content

Commit 6637d72

Browse files
author
Sjoerd Meijer
committed
[Lint] Add check for intrinsic get.active.lane.mask
As @efriedma pointed out in D86301, this "not equal to 0 check" of get.active.lane.mask's second operand needs to live here in Lint and not the Verifier. Differential Revision: https://reviews.llvm.org/D87228
1 parent a2fb544 commit 6637d72

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

llvm/lib/Analysis/Lint.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ void Lint::visitCallBase(CallBase &I) {
365365
visitMemoryReference(I, I.getArgOperand(0), MemoryLocation::UnknownSize,
366366
None, nullptr, MemRef::Read | MemRef::Write);
367367
break;
368+
case Intrinsic::get_active_lane_mask:
369+
if (auto *TripCount = dyn_cast<ConstantInt>(I.getArgOperand(1)))
370+
Assert(!TripCount->isZero(), "get_active_lane_mask: operand #2 "
371+
"must be greater than 0", &I);
372+
break;
368373
}
369374
}
370375

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; RUN: opt -lint -disable-output < %s 2>&1 | FileCheck %s
2+
3+
define <4 x i1> @t1(i32 %IV) {
4+
;
5+
; CHECK: get_active_lane_mask: operand #2 must be greater than 0
6+
; CHECK-NEXT: %res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 0)
7+
;
8+
%res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 0)
9+
ret <4 x i1> %res
10+
}
11+
12+
define <4 x i1> @t2(i32 %IV) {
13+
;
14+
; CHECK-NOT: get_active_lane_mask
15+
; CHECK-NOT: call <4 x i1> @llvm.get.active.lane.mask
16+
;
17+
%res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 1)
18+
ret <4 x i1> %res
19+
}
20+
21+
define <4 x i1> @t3(i32 %IV) {
22+
;
23+
; CHECK-NOT: get_active_lane_mask
24+
; CHECK-NOT: call <4 x i1> @llvm.get.active.lane.mask
25+
;
26+
%res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 -1)
27+
ret <4 x i1> %res
28+
}
29+
30+
define <4 x i1> @t4(i32 %IV, i32 %TC) {
31+
;
32+
; CHECK-NOT: get_active_lane_mask
33+
; CHECK-NOT: call <4 x i1> @llvm.get.active.lane.mask
34+
;
35+
%res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 %TC)
36+
ret <4 x i1> %res
37+
}
38+
39+
declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32, i32)

0 commit comments

Comments
 (0)