Skip to content

Commit 0cd28b5

Browse files
V-FEXrtAnthony Tran
authored andcommitted
[DirectX] Make firstbithigh intrinsic use first arg as overload type (llvm#145401)
Sibling to llvm#145350 part of llvm#144966 firstbituhigh and firstbitshigh should use the first arg for overloads instead of the return type since the return is always i32
1 parent efd055f commit 0cd28b5

File tree

3 files changed

+72
-40
lines changed

3 files changed

+72
-40
lines changed

llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ bool DirectXTTIImpl::isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
3131
case Intrinsic::dx_asdouble:
3232
case Intrinsic::dx_isinf:
3333
case Intrinsic::dx_firstbitlow:
34+
case Intrinsic::dx_firstbituhigh:
35+
case Intrinsic::dx_firstbitshigh:
3436
return OpdIdx == 0;
3537
default:
3638
return OpdIdx == -1;

llvm/test/CodeGen/DirectX/firstbithigh.ll

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,118 @@
44

55
define noundef i32 @test_firstbithigh_ushort(i16 noundef %a) {
66
entry:
7-
; CHECK: call i32 @dx.op.unaryBits.i16(i32 33, i16 %{{.*}}) #[[#ATTR:]]
7+
; CHECK: call i32 @dx.op.unaryBits.i16(i32 33, i16 %{{.*}})
88
%elt.firstbithigh = call i32 @llvm.dx.firstbituhigh.i16(i16 %a)
99
ret i32 %elt.firstbithigh
1010
}
1111

1212
define noundef i32 @test_firstbithigh_short(i16 noundef %a) {
1313
entry:
14-
; CHECK: call i32 @dx.op.unaryBits.i16(i32 34, i16 %{{.*}}) #[[#ATTR]]
14+
; CHECK: call i32 @dx.op.unaryBits.i16(i32 34, i16 %{{.*}})
1515
%elt.firstbithigh = call i32 @llvm.dx.firstbitshigh.i16(i16 %a)
1616
ret i32 %elt.firstbithigh
1717
}
1818

1919
define noundef i32 @test_firstbithigh_uint(i32 noundef %a) {
2020
entry:
21-
; CHECK: call i32 @dx.op.unaryBits.i32(i32 33, i32 %{{.*}}) #[[#ATTR]]
21+
; CHECK: call i32 @dx.op.unaryBits.i32(i32 33, i32 %{{.*}})
2222
%elt.firstbithigh = call i32 @llvm.dx.firstbituhigh.i32(i32 %a)
2323
ret i32 %elt.firstbithigh
2424
}
2525

2626
define noundef i32 @test_firstbithigh_int(i32 noundef %a) {
2727
entry:
28-
; CHECK: call i32 @dx.op.unaryBits.i32(i32 34, i32 %{{.*}}) #[[#ATTR]]
28+
; CHECK: call i32 @dx.op.unaryBits.i32(i32 34, i32 %{{.*}})
2929
%elt.firstbithigh = call i32 @llvm.dx.firstbitshigh.i32(i32 %a)
3030
ret i32 %elt.firstbithigh
3131
}
3232

3333
define noundef i32 @test_firstbithigh_ulong(i64 noundef %a) {
3434
entry:
35-
; CHECK: call i32 @dx.op.unaryBits.i64(i32 33, i64 %{{.*}}) #[[#ATTR]]
35+
; CHECK: call i32 @dx.op.unaryBits.i64(i32 33, i64 %{{.*}})
3636
%elt.firstbithigh = call i32 @llvm.dx.firstbituhigh.i64(i64 %a)
3737
ret i32 %elt.firstbithigh
3838
}
3939

4040
define noundef i32 @test_firstbithigh_long(i64 noundef %a) {
4141
entry:
42-
; CHECK: call i32 @dx.op.unaryBits.i64(i32 34, i64 %{{.*}}) #[[#ATTR]]
42+
; CHECK: call i32 @dx.op.unaryBits.i64(i32 34, i64 %{{.*}})
4343
%elt.firstbithigh = call i32 @llvm.dx.firstbitshigh.i64(i64 %a)
4444
ret i32 %elt.firstbithigh
4545
}
4646

4747
define noundef <4 x i32> @test_firstbituhigh_vec4_i32(<4 x i32> noundef %a) {
4848
entry:
4949
; CHECK: [[ee0:%.*]] = extractelement <4 x i32> %a, i64 0
50-
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee0]]) #[[#ATTR]]
50+
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee0]])
5151
; CHECK: [[ee1:%.*]] = extractelement <4 x i32> %a, i64 1
52-
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee1]]) #[[#ATTR]]
52+
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee1]])
5353
; CHECK: [[ee2:%.*]] = extractelement <4 x i32> %a, i64 2
54-
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee2]]) #[[#ATTR]]
54+
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee2]])
5555
; CHECK: [[ee3:%.*]] = extractelement <4 x i32> %a, i64 3
56-
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee3]]) #[[#ATTR]]
57-
; CHECK: insertelement <4 x i32> poison, i32 [[ie0]], i64 0
58-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie1]], i64 1
59-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie2]], i64 2
60-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie3]], i64 3
56+
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee3]])
57+
; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0
58+
; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1
59+
; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2
60+
; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3
61+
; CHECK: ret <4 x i32> [[rt3]]
6162
%2 = call <4 x i32> @llvm.dx.firstbituhigh.v4i32(<4 x i32> %a)
6263
ret <4 x i32> %2
6364
}
6465

6566
define noundef <4 x i32> @test_firstbitshigh_vec4_i32(<4 x i32> noundef %a) {
6667
entry:
6768
; CHECK: [[ee0:%.*]] = extractelement <4 x i32> %a, i64 0
68-
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee0]]) #[[#ATTR]]
69+
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee0]])
6970
; CHECK: [[ee1:%.*]] = extractelement <4 x i32> %a, i64 1
70-
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee1]]) #[[#ATTR]]
71+
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee1]])
7172
; CHECK: [[ee2:%.*]] = extractelement <4 x i32> %a, i64 2
72-
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee2]]) #[[#ATTR]]
73+
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee2]])
7374
; CHECK: [[ee3:%.*]] = extractelement <4 x i32> %a, i64 3
74-
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee3]]) #[[#ATTR]]
75-
; CHECK: insertelement <4 x i32> poison, i32 [[ie0]], i64 0
76-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie1]], i64 1
77-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie2]], i64 2
78-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie3]], i64 3
75+
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee3]])
76+
; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0
77+
; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1
78+
; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2
79+
; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3
80+
; CHECK: ret <4 x i32> [[rt3]]
7981
%2 = call <4 x i32> @llvm.dx.firstbitshigh.v4i32(<4 x i32> %a)
8082
ret <4 x i32> %2
8183
}
8284

83-
; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}
84-
85-
declare i32 @llvm.dx.firstbituhigh.i16(i16)
86-
declare i32 @llvm.dx.firstbituhigh.i32(i32)
87-
declare i32 @llvm.dx.firstbituhigh.i64(i64)
88-
declare <4 x i32> @llvm.dx.firstbituhigh.v4i32(<4 x i32>)
85+
define noundef <4 x i32> @test_firstbituhigh_vec4_i16(<4 x i16> noundef %a) {
86+
entry:
87+
; CHECK: [[ee0:%.*]] = extractelement <4 x i16> %a, i64 0
88+
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee0]])
89+
; CHECK: [[ee1:%.*]] = extractelement <4 x i16> %a, i64 1
90+
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee1]])
91+
; CHECK: [[ee2:%.*]] = extractelement <4 x i16> %a, i64 2
92+
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee2]])
93+
; CHECK: [[ee3:%.*]] = extractelement <4 x i16> %a, i64 3
94+
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee3]])
95+
; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0
96+
; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1
97+
; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2
98+
; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3
99+
; CHECK: ret <4 x i32> [[rt3]]
100+
%2 = call <4 x i32> @llvm.dx.firstbituhigh.v4i16(<4 x i16> %a)
101+
ret <4 x i32> %2
102+
}
89103

90-
declare i32 @llvm.dx.firstbitshigh.i16(i16)
91-
declare i32 @llvm.dx.firstbitshigh.i32(i32)
92-
declare i32 @llvm.dx.firstbitshigh.i64(i64)
93-
declare <4 x i32> @llvm.dx.firstbitshigh.v4i32(<4 x i32>)
104+
define noundef <4 x i32> @test_firstbitshigh_vec4_i16(<4 x i16> noundef %a) {
105+
entry:
106+
; CHECK: [[ee0:%.*]] = extractelement <4 x i16> %a, i64 0
107+
; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee0]])
108+
; CHECK: [[ee1:%.*]] = extractelement <4 x i16> %a, i64 1
109+
; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee1]])
110+
; CHECK: [[ee2:%.*]] = extractelement <4 x i16> %a, i64 2
111+
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee2]])
112+
; CHECK: [[ee3:%.*]] = extractelement <4 x i16> %a, i64 3
113+
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee3]])
114+
; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0
115+
; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1
116+
; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2
117+
; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3
118+
; CHECK: ret <4 x i32> [[rt3]]
119+
%2 = call <4 x i32> @llvm.dx.firstbitshigh.v4i16(<4 x i16> %a)
120+
ret <4 x i32> %2
121+
}

llvm/test/CodeGen/DirectX/firstbitlow.ll

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ entry:
3333
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 32, i32 [[ee2]])
3434
; CHECK: [[ee3:%.*]] = extractelement <4 x i32> %a, i64 3
3535
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 32, i32 [[ee3]])
36-
; CHECK: insertelement <4 x i32> poison, i32 [[ie0]], i64 0
37-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie1]], i64 1
38-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie2]], i64 2
39-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie3]], i64 3
36+
; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0
37+
; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1
38+
; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2
39+
; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3
40+
; CHECK: ret <4 x i32> [[rt3]]
4041
%2 = call <4 x i32> @llvm.dx.firstbitlow.v4i32(<4 x i32> %a)
4142
ret <4 x i32> %2
4243
}
@@ -51,10 +52,11 @@ entry:
5152
; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i16(i32 32, i16 [[ee2]])
5253
; CHECK: [[ee3:%.*]] = extractelement <4 x i16> %a, i64 3
5354
; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i16(i32 32, i16 [[ee3]])
54-
; CHECK: insertelement <4 x i32> poison, i32 [[ie0]], i64 0
55-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie1]], i64 1
56-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie2]], i64 2
57-
; CHECK: insertelement <4 x i32> %{{.*}}, i32 [[ie3]], i64 3
55+
; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0
56+
; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1
57+
; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2
58+
; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3
59+
; CHECK: ret <4 x i32> [[rt3]]
5860
%2 = call <4 x i32> @llvm.dx.firstbitlow.v4i16(<4 x i16> %a)
5961
ret <4 x i32> %2
6062
}

0 commit comments

Comments
 (0)