Skip to content

Commit ad12590

Browse files
[InstCombine] Added tests for PR50172, NFC
1 parent b817ea7 commit ad12590

File tree

1 file changed

+120
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -S -instcombine | FileCheck %s
3+
4+
declare i32 @llvm.cttz.i32(i32, i1)
5+
declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1)
6+
declare void @use(i32)
7+
8+
define i32 @cttz_zext_zero_undef(i16 %x) {
9+
; CHECK-LABEL: @cttz_zext_zero_undef(
10+
; CHECK-NEXT: [[Z:%.*]] = zext i16 [[X:%.*]] to i32
11+
; CHECK-NEXT: [[TZ:%.*]] = call i32 @llvm.cttz.i32(i32 [[Z]], i1 true), !range [[RNG0:![0-9]+]]
12+
; CHECK-NEXT: ret i32 [[TZ]]
13+
;
14+
%z = zext i16 %x to i32
15+
%tz = call i32 @llvm.cttz.i32(i32 %z, i1 true)
16+
ret i32 %tz
17+
}
18+
19+
define i32 @cttz_zext_zero_def(i16 %x) {
20+
; CHECK-LABEL: @cttz_zext_zero_def(
21+
; CHECK-NEXT: [[Z:%.*]] = zext i16 [[X:%.*]] to i32
22+
; CHECK-NEXT: [[TZ:%.*]] = call i32 @llvm.cttz.i32(i32 [[Z]], i1 false), !range [[RNG0]]
23+
; CHECK-NEXT: ret i32 [[TZ]]
24+
;
25+
%z = zext i16 %x to i32
26+
%tz = call i32 @llvm.cttz.i32(i32 %z, i1 false)
27+
ret i32 %tz
28+
}
29+
30+
define i32 @cttz_zext_zero_undef_extra_use(i16 %x) {
31+
; CHECK-LABEL: @cttz_zext_zero_undef_extra_use(
32+
; CHECK-NEXT: [[Z:%.*]] = zext i16 [[X:%.*]] to i32
33+
; CHECK-NEXT: call void @use(i32 [[Z]])
34+
; CHECK-NEXT: [[TZ:%.*]] = call i32 @llvm.cttz.i32(i32 [[Z]], i1 true), !range [[RNG0]]
35+
; CHECK-NEXT: ret i32 [[TZ]]
36+
;
37+
%z = zext i16 %x to i32
38+
call void @use(i32 %z)
39+
%tz = call i32 @llvm.cttz.i32(i32 %z, i1 true)
40+
ret i32 %tz
41+
}
42+
43+
define <2 x i64> @cttz_zext_zero_undef_vec(<2 x i32> %x) {
44+
; CHECK-LABEL: @cttz_zext_zero_undef_vec(
45+
; CHECK-NEXT: [[Z:%.*]] = zext <2 x i32> [[X:%.*]] to <2 x i64>
46+
; CHECK-NEXT: [[TZ:%.*]] = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> [[Z]], i1 true)
47+
; CHECK-NEXT: ret <2 x i64> [[TZ]]
48+
;
49+
%z = zext <2 x i32> %x to <2 x i64>
50+
%tz = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %z, i1 true)
51+
ret <2 x i64> %tz
52+
}
53+
54+
define <2 x i64> @cttz_zext_zero_def_vec(<2 x i32> %x) {
55+
; CHECK-LABEL: @cttz_zext_zero_def_vec(
56+
; CHECK-NEXT: [[Z:%.*]] = zext <2 x i32> [[X:%.*]] to <2 x i64>
57+
; CHECK-NEXT: [[TZ:%.*]] = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> [[Z]], i1 false)
58+
; CHECK-NEXT: ret <2 x i64> [[TZ]]
59+
;
60+
%z = zext <2 x i32> %x to <2 x i64>
61+
%tz = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %z, i1 false)
62+
ret <2 x i64> %tz
63+
}
64+
65+
define i32 @cttz_sext_zero_undef(i16 %x) {
66+
; CHECK-LABEL: @cttz_sext_zero_undef(
67+
; CHECK-NEXT: [[S:%.*]] = sext i16 [[X:%.*]] to i32
68+
; CHECK-NEXT: [[TZ:%.*]] = call i32 @llvm.cttz.i32(i32 [[S]], i1 true), !range [[RNG0]]
69+
; CHECK-NEXT: ret i32 [[TZ]]
70+
;
71+
%s = sext i16 %x to i32
72+
%tz = call i32 @llvm.cttz.i32(i32 %s, i1 true)
73+
ret i32 %tz
74+
}
75+
76+
define i32 @cttz_sext_zero_def(i16 %x) {
77+
; CHECK-LABEL: @cttz_sext_zero_def(
78+
; CHECK-NEXT: [[S:%.*]] = zext i16 [[X:%.*]] to i32
79+
; CHECK-NEXT: [[TZ:%.*]] = call i32 @llvm.cttz.i32(i32 [[S]], i1 false), !range [[RNG0]]
80+
; CHECK-NEXT: ret i32 [[TZ]]
81+
;
82+
%s = zext i16 %x to i32
83+
%tz = call i32 @llvm.cttz.i32(i32 %s, i1 false)
84+
ret i32 %tz
85+
}
86+
87+
define i32 @cttz_zext_sero_undef_extra_use(i16 %x) {
88+
; CHECK-LABEL: @cttz_zext_sero_undef_extra_use(
89+
; CHECK-NEXT: [[S:%.*]] = sext i16 [[X:%.*]] to i32
90+
; CHECK-NEXT: call void @use(i32 [[S]])
91+
; CHECK-NEXT: [[TZ:%.*]] = call i32 @llvm.cttz.i32(i32 [[S]], i1 true), !range [[RNG0]]
92+
; CHECK-NEXT: ret i32 [[TZ]]
93+
;
94+
%s = sext i16 %x to i32
95+
call void @use(i32 %s)
96+
%tz = call i32 @llvm.cttz.i32(i32 %s, i1 true)
97+
ret i32 %tz
98+
}
99+
100+
define <2 x i64> @cttz_sext_zero_undef_vec(<2 x i32> %x) {
101+
; CHECK-LABEL: @cttz_sext_zero_undef_vec(
102+
; CHECK-NEXT: [[S:%.*]] = sext <2 x i32> [[X:%.*]] to <2 x i64>
103+
; CHECK-NEXT: [[TZ:%.*]] = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> [[S]], i1 true)
104+
; CHECK-NEXT: ret <2 x i64> [[TZ]]
105+
;
106+
%s = sext <2 x i32> %x to <2 x i64>
107+
%tz = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %s, i1 true)
108+
ret <2 x i64> %tz
109+
}
110+
111+
define <2 x i64> @cttz_sext_zero_def_vec(<2 x i32> %x) {
112+
; CHECK-LABEL: @cttz_sext_zero_def_vec(
113+
; CHECK-NEXT: [[S:%.*]] = sext <2 x i32> [[X:%.*]] to <2 x i64>
114+
; CHECK-NEXT: [[TZ:%.*]] = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> [[S]], i1 false)
115+
; CHECK-NEXT: ret <2 x i64> [[TZ]]
116+
;
117+
%s = sext <2 x i32> %x to <2 x i64>
118+
%tz = tail call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %s, i1 false)
119+
ret <2 x i64> %tz
120+
}

0 commit comments

Comments
 (0)