1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
6 define i32 @and_signbit_shl(i32 %x) {
7 ; CHECK-LABEL: @and_signbit_shl(
8 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
9 ; CHECK-NEXT: [[R:%.*]] = and i32 [[T0]], -16777216
10 ; CHECK-NEXT: ret i32 [[R]]
12 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
16 define i32 @and_nosignbit_shl(i32 %x) {
17 ; CHECK-LABEL: @and_nosignbit_shl(
18 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
19 ; CHECK-NEXT: [[R:%.*]] = and i32 [[T0]], -16777216
20 ; CHECK-NEXT: ret i32 [[R]]
22 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
27 define i32 @or_signbit_shl(i32 %x) {
28 ; CHECK-LABEL: @or_signbit_shl(
29 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
30 ; CHECK-NEXT: [[R:%.*]] = or i32 [[T0]], -16777216
31 ; CHECK-NEXT: ret i32 [[R]]
33 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
37 define i32 @or_nosignbit_shl(i32 %x) {
38 ; CHECK-LABEL: @or_nosignbit_shl(
39 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
40 ; CHECK-NEXT: [[R:%.*]] = or i32 [[T0]], -16777216
41 ; CHECK-NEXT: ret i32 [[R]]
43 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
48 define i32 @xor_signbit_shl(i32 %x) {
49 ; CHECK-LABEL: @xor_signbit_shl(
50 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
51 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[T0]], -16777216
52 ; CHECK-NEXT: ret i32 [[R]]
54 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
58 define i32 @xor_nosignbit_shl(i32 %x) {
59 ; CHECK-LABEL: @xor_nosignbit_shl(
60 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
61 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[T0]], -16777216
62 ; CHECK-NEXT: ret i32 [[R]]
64 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
69 define i32 @add_signbit_shl(i32 %x) {
70 ; CHECK-LABEL: @add_signbit_shl(
71 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
72 ; CHECK-NEXT: [[R:%.*]] = add i32 [[T0]], -16777216
73 ; CHECK-NEXT: ret i32 [[R]]
75 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
79 define i32 @add_nosignbit_shl(i32 %x) {
80 ; CHECK-LABEL: @add_nosignbit_shl(
81 ; CHECK-NEXT: [[T0:%.*]] = shl i32 [[X:%.*]], 8
82 ; CHECK-NEXT: [[R:%.*]] = add i32 [[T0]], -16777216
83 ; CHECK-NEXT: ret i32 [[R]]
85 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
92 define i32 @and_signbit_lshr(i32 %x) {
93 ; CHECK-LABEL: @and_signbit_lshr(
94 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
95 ; CHECK-NEXT: [[R:%.*]] = and i32 [[T0]], 16776960
96 ; CHECK-NEXT: ret i32 [[R]]
98 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
102 define i32 @and_nosignbit_lshr(i32 %x) {
103 ; CHECK-LABEL: @and_nosignbit_lshr(
104 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
105 ; CHECK-NEXT: [[R:%.*]] = and i32 [[T0]], 8388352
106 ; CHECK-NEXT: ret i32 [[R]]
108 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
113 define i32 @or_signbit_lshr(i32 %x) {
114 ; CHECK-LABEL: @or_signbit_lshr(
115 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
116 ; CHECK-NEXT: [[R:%.*]] = or i32 [[T0]], 16776960
117 ; CHECK-NEXT: ret i32 [[R]]
119 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
123 define i32 @or_nosignbit_lshr(i32 %x) {
124 ; CHECK-LABEL: @or_nosignbit_lshr(
125 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
126 ; CHECK-NEXT: [[R:%.*]] = or i32 [[T0]], 8388352
127 ; CHECK-NEXT: ret i32 [[R]]
129 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
134 define i32 @xor_signbit_lshr(i32 %x) {
135 ; CHECK-LABEL: @xor_signbit_lshr(
136 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
137 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[T0]], 16776960
138 ; CHECK-NEXT: ret i32 [[R]]
140 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
144 define i32 @xor_nosignbit_lshr(i32 %x) {
145 ; CHECK-LABEL: @xor_nosignbit_lshr(
146 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
147 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[T0]], 8388352
148 ; CHECK-NEXT: ret i32 [[R]]
150 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
155 define i32 @add_signbit_lshr(i32 %x) {
156 ; CHECK-LABEL: @add_signbit_lshr(
157 ; CHECK-NEXT: [[T0:%.*]] = add i32 [[X:%.*]], -65536
158 ; CHECK-NEXT: [[R:%.*]] = lshr i32 [[T0]], 8
159 ; CHECK-NEXT: ret i32 [[R]]
161 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
165 define i32 @add_nosignbit_lshr(i32 %x) {
166 ; CHECK-LABEL: @add_nosignbit_lshr(
167 ; CHECK-NEXT: [[T0:%.*]] = add i32 [[X:%.*]], 2147418112
168 ; CHECK-NEXT: [[R:%.*]] = lshr i32 [[T0]], 8
169 ; CHECK-NEXT: ret i32 [[R]]
171 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000
176 ; arithmetic shift right
178 define i32 @and_signbit_ashr(i32 %x) {
179 ; CHECK-LABEL: @and_signbit_ashr(
180 ; CHECK-NEXT: [[T0:%.*]] = ashr i32 [[X:%.*]], 8
181 ; CHECK-NEXT: [[R:%.*]] = and i32 [[T0]], -256
182 ; CHECK-NEXT: ret i32 [[R]]
184 %t0 = and i32 %x, 4294901760 ; 0xFFFF0000
188 define i32 @and_nosignbit_ashr(i32 %x) {
189 ; CHECK-LABEL: @and_nosignbit_ashr(
190 ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 8
191 ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[T0]], 8388352
192 ; CHECK-NEXT: ret i32 [[TMP1]]
194 %t0 = and i32 %x, 2147418112 ; 0x7FFF0000
199 define i32 @or_signbit_ashr(i32 %x) {
200 ; CHECK-LABEL: @or_signbit_ashr(
201 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 8
202 ; CHECK-NEXT: [[R:%.*]] = or i32 [[TMP1]], -256
203 ; CHECK-NEXT: ret i32 [[R]]
205 %t0 = or i32 %x, 4294901760 ; 0xFFFF0000
209 define i32 @or_nosignbit_ashr(i32 %x) {
210 ; CHECK-LABEL: @or_nosignbit_ashr(
211 ; CHECK-NEXT: [[T0:%.*]] = ashr i32 [[X:%.*]], 8
212 ; CHECK-NEXT: [[R:%.*]] = or i32 [[T0]], 8388352
213 ; CHECK-NEXT: ret i32 [[R]]
215 %t0 = or i32 %x, 2147418112 ; 0x7FFF0000
220 define i32 @xor_signbit_ashr(i32 %x) {
221 ; CHECK-LABEL: @xor_signbit_ashr(
222 ; CHECK-NEXT: [[T0:%.*]] = ashr i32 [[X:%.*]], 8
223 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[T0]], -256
224 ; CHECK-NEXT: ret i32 [[R]]
226 %t0 = xor i32 %x, 4294901760 ; 0xFFFF0000
230 define i32 @xor_nosignbit_ashr(i32 %x) {
231 ; CHECK-LABEL: @xor_nosignbit_ashr(
232 ; CHECK-NEXT: [[T0:%.*]] = ashr i32 [[X:%.*]], 8
233 ; CHECK-NEXT: [[R:%.*]] = xor i32 [[T0]], 8388352
234 ; CHECK-NEXT: ret i32 [[R]]
236 %t0 = xor i32 %x, 2147418112 ; 0x7FFF0000
241 define i32 @add_signbit_ashr(i32 %x) {
242 ; CHECK-LABEL: @add_signbit_ashr(
243 ; CHECK-NEXT: [[T0:%.*]] = add i32 [[X:%.*]], -65536
244 ; CHECK-NEXT: [[R:%.*]] = ashr i32 [[T0]], 8
245 ; CHECK-NEXT: ret i32 [[R]]
247 %t0 = add i32 %x, 4294901760 ; 0xFFFF0000
251 define i32 @add_nosignbit_ashr(i32 %x) {
252 ; CHECK-LABEL: @add_nosignbit_ashr(
253 ; CHECK-NEXT: [[T0:%.*]] = add i32 [[X:%.*]], 2147418112
254 ; CHECK-NEXT: [[R:%.*]] = ashr i32 [[T0]], 8
255 ; CHECK-NEXT: ret i32 [[R]]
257 %t0 = add i32 %x, 2147418112 ; 0x7FFF0000