annotate test/Transforms/InstCombine/icmp-shl-nsw.ll @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 ; If the (shl x, C) preserved the sign and this is a sign test,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 ; compare the LHS operand instead
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 define i1 @icmp_shl_nsw_sgt(i32 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 ; CHECK-LABEL: @icmp_shl_nsw_sgt(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 %shl = shl nsw i32 %x, 21
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 %cmp = icmp sgt i32 %shl, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 define i1 @icmp_shl_nsw_sge0(i32 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 ; CHECK-LABEL: @icmp_shl_nsw_sge0(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %x, -1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 %shl = shl nsw i32 %x, 21
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 %cmp = icmp sge i32 %shl, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 define i1 @icmp_shl_nsw_sge1(i32 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 ; CHECK-LABEL: @icmp_shl_nsw_sge1(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 %shl = shl nsw i32 %x, 21
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 %cmp = icmp sge i32 %shl, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 define <2 x i1> @icmp_shl_nsw_sge1_vec(<2 x i32> %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 ; CHECK-LABEL: @icmp_shl_nsw_sge1_vec(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i32> %x, zeroinitializer
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 %shl = shl nsw <2 x i32> %x, <i32 21, i32 21>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 %cmp = icmp sge <2 x i32> %shl, <i32 1, i32 1>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 ret <2 x i1> %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 ; Checks for icmp (eq|ne) (shl x, C), 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49 define i1 @icmp_shl_nsw_eq(i32 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 ; CHECK-LABEL: @icmp_shl_nsw_eq(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54 %mul = shl nsw i32 %x, 5
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 %cmp = icmp eq i32 %mul, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
56 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
57 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
58
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
59 define <2 x i1> @icmp_shl_nsw_eq_vec(<2 x i32> %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
60 ; CHECK-LABEL: @icmp_shl_nsw_eq_vec(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
61 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> %x, zeroinitializer
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
62 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
63 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
64 %mul = shl nsw <2 x i32> %x, <i32 5, i32 5>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
65 %cmp = icmp eq <2 x i32> %mul, zeroinitializer
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
66 ret <2 x i1> %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
67 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
68
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
69 ; icmp sgt with shl nsw with a constant compare operand and constant
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
70 ; shift amount can always be reduced to icmp sgt alone.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
71
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
72 ; Known bits analysis turns this into an equality predicate.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
73
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
74 define i1 @icmp_sgt1(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
75 ; CHECK-LABEL: @icmp_sgt1(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
76 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 %x, -64
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
77 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
78 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
79 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
80 %cmp = icmp sgt i8 %shl, -128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
81 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
82 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
83
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
84 define i1 @icmp_sgt2(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
85 ; CHECK-LABEL: @icmp_sgt2(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
86 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, -64
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
87 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
88 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
89 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
90 %cmp = icmp sgt i8 %shl, -127
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
91 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
92 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
93
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
94 define i1 @icmp_sgt3(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
95 ; CHECK-LABEL: @icmp_sgt3(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
96 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, -8
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
97 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
98 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
99 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
100 %cmp = icmp sgt i8 %shl, -16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
101 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
102 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
103
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
104 define i1 @icmp_sgt4(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
105 ; CHECK-LABEL: @icmp_sgt4(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
106 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, -1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
107 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
108 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
109 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
110 %cmp = icmp sgt i8 %shl, -2
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
111 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
112 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
113
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
114 ; x >s -1 is a sign bit test.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
115 ; x >s 0 is a sign bit test.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
116
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
117 define i1 @icmp_sgt5(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
118 ; CHECK-LABEL: @icmp_sgt5(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
119 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
120 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
121 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
122 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
123 %cmp = icmp sgt i8 %shl, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
124 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
125 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
126
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
127 define i1 @icmp_sgt6(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
128 ; CHECK-LABEL: @icmp_sgt6(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
129 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, 8
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
130 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
131 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
132 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
133 %cmp = icmp sgt i8 %shl, 16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
134 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
135 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
136
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
137 define i1 @icmp_sgt7(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
138 ; CHECK-LABEL: @icmp_sgt7(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
139 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, 62
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
140 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
141 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
142 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
143 %cmp = icmp sgt i8 %shl, 124
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
144 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
145 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
146
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
147 ; Known bits analysis turns this into an equality predicate.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
148
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
149 define i1 @icmp_sgt8(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
150 ; CHECK-LABEL: @icmp_sgt8(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
151 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 %x, 63
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
152 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
153 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
154 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
155 %cmp = icmp sgt i8 %shl, 125
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
156 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
157 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
158
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
159 ; Compares with 126 and 127 are recognized as always false.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
160
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
161 ; Known bits analysis turns this into an equality predicate.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
162
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
163 define i1 @icmp_sgt9(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
164 ; CHECK-LABEL: @icmp_sgt9(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
165 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 %x, -1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
166 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
167 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
168 %shl = shl nsw i8 %x, 7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
169 %cmp = icmp sgt i8 %shl, -128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
170 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
171 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
172
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
173 define i1 @icmp_sgt10(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
174 ; CHECK-LABEL: @icmp_sgt10(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
175 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, -1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
176 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
177 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
178 %shl = shl nsw i8 %x, 7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
179 %cmp = icmp sgt i8 %shl, -127
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
180 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
181 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
182
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
183 define i1 @icmp_sgt11(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
184 ; CHECK-LABEL: @icmp_sgt11(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
185 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 %x, -1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
186 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
187 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
188 %shl = shl nsw i8 %x, 7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
189 %cmp = icmp sgt i8 %shl, -2
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
190 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
191 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
192
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
193 ; Splat vector version should fold the same way.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
194
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
195 define <2 x i1> @icmp_sgt11_vec(<2 x i8> %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
196 ; CHECK-LABEL: @icmp_sgt11_vec(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
197 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> %x, <i8 -1, i8 -1>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
198 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
199 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
200 %shl = shl nsw <2 x i8> %x, <i8 7, i8 7>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
201 %cmp = icmp sgt <2 x i8> %shl, <i8 -2, i8 -2>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
202 ret <2 x i1> %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
203 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
204
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
205 ; Known bits analysis returns false for compares with >=0.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
206
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
208 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
209 ; Repeat the shl nsw + sgt tests with predicate changed to 'sle'.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
210 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
211 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
212
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
213 ; Known bits analysis turns this into an equality predicate.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
214
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
215 define i1 @icmp_sle1(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
216 ; CHECK-LABEL: @icmp_sle1(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
217 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 %x, -64
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
218 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
219 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
220 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
221 %cmp = icmp sle i8 %shl, -128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
222 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
223 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
224
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
225 define i1 @icmp_sle2(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
226 ; CHECK-LABEL: @icmp_sle2(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
227 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, -63
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
228 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
229 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
230 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
231 %cmp = icmp sle i8 %shl, -127
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
232 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
233 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
234
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
235 define i1 @icmp_sle3(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
236 ; CHECK-LABEL: @icmp_sle3(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
237 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, -7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
238 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
239 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
240 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
241 %cmp = icmp sle i8 %shl, -16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
242 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
243 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
244
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
245 define i1 @icmp_sle4(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
246 ; CHECK-LABEL: @icmp_sle4(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
247 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
248 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
249 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
250 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
251 %cmp = icmp sle i8 %shl, -2
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
252 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
253 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
254
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
255 ; x <=s -1 is a sign bit test.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
256 ; x <=s 0 is a sign bit test.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
257
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
258 define i1 @icmp_sle5(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
259 ; CHECK-LABEL: @icmp_sle5(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
260 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
261 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
262 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
263 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
264 %cmp = icmp sle i8 %shl, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
265 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
266 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
267
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
268 define i1 @icmp_sle6(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
269 ; CHECK-LABEL: @icmp_sle6(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
270 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, 9
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
271 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
272 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
273 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
274 %cmp = icmp sle i8 %shl, 16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
275 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
276 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
277
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
278 define i1 @icmp_sle7(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
279 ; CHECK-LABEL: @icmp_sle7(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
280 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, 63
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
281 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
282 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
283 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
284 %cmp = icmp sle i8 %shl, 124
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
285 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
286 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
287
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
288 ; Known bits analysis turns this into an equality predicate.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
289
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
290 define i1 @icmp_sle8(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
291 ; CHECK-LABEL: @icmp_sle8(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
292 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 %x, 63
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
293 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
294 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
295 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
296 %cmp = icmp sle i8 %shl, 125
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
297 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
298 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
299
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
300 ; Compares with 126 and 127 are recognized as always true.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
301
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
302 ; Known bits analysis turns this into an equality predicate.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
303
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
304 define i1 @icmp_sle9(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
305 ; CHECK-LABEL: @icmp_sle9(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
306 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 %x, -1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
307 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
308 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
309 %shl = shl nsw i8 %x, 7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
310 %cmp = icmp sle i8 %shl, -128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
311 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
312 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
313
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
314 define i1 @icmp_sle10(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
315 ; CHECK-LABEL: @icmp_sle10(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
316 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
317 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
318 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
319 %shl = shl nsw i8 %x, 7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
320 %cmp = icmp sle i8 %shl, -127
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
321 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
322 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
323
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
324 define i1 @icmp_sle11(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
325 ; CHECK-LABEL: @icmp_sle11(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
326 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 %x, 0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
327 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
328 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
329 %shl = shl nsw i8 %x, 7
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
330 %cmp = icmp sle i8 %shl, -2
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
331 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
332 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
333
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
334 ; Some of the earlier sgt/sle tests are transformed to eq/ne, but try a couple
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
335 ; of those explicitly, so we know no intermediate transforms are necessary.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
336
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
337 define i1 @icmp_eq1(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
338 ; CHECK-LABEL: @icmp_eq1(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
339 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 %x, 6
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
340 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
341 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
342 %shl = shl nsw i8 %x, 1
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
343 %cmp = icmp eq i8 %shl, 12
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
344 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
345 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
346
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
347 define i1 @icmp_ne1(i8 %x) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
348 ; CHECK-LABEL: @icmp_ne1(
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
349 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 %x, -2
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
350 ; CHECK-NEXT: ret i1 [[CMP]]
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
351 ;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
352 %shl = shl nsw i8 %x, 6
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
353 %cmp = icmp ne i8 %shl, -128
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
354 ret i1 %cmp
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
355 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
356