@@ -179,8 +179,8 @@ define i47 @sext_zext_apint2(i11 %A) {
179
179
define i32 @masked_bit_set (i32 %x , i32 %y ) {
180
180
; CHECK-LABEL: @masked_bit_set(
181
181
; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], [[Y:%.*]]
182
- ; CHECK-NEXT: [[TMP2 :%.*]] = and i32 [[TMP1]], 1
183
- ; CHECK-NEXT: ret i32 [[TMP2 ]]
182
+ ; CHECK-NEXT: [[R :%.*]] = and i32 [[TMP1]], 1
183
+ ; CHECK-NEXT: ret i32 [[R ]]
184
184
;
185
185
%sh1 = shl i32 1 , %y
186
186
%and = and i32 %sh1 , %x
@@ -193,8 +193,8 @@ define <2 x i32> @masked_bit_clear(<2 x i32> %x, <2 x i32> %y) {
193
193
; CHECK-LABEL: @masked_bit_clear(
194
194
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], <i32 -1, i32 -1>
195
195
; CHECK-NEXT: [[TMP2:%.*]] = lshr <2 x i32> [[TMP1]], [[Y:%.*]]
196
- ; CHECK-NEXT: [[TMP3 :%.*]] = and <2 x i32> [[TMP2]], <i32 1, i32 1>
197
- ; CHECK-NEXT: ret <2 x i32> [[TMP3 ]]
196
+ ; CHECK-NEXT: [[R :%.*]] = and <2 x i32> [[TMP2]], <i32 1, i32 1>
197
+ ; CHECK-NEXT: ret <2 x i32> [[R ]]
198
198
;
199
199
%sh1 = shl <2 x i32 > <i32 1 , i32 1 >, %y
200
200
%and = and <2 x i32 > %sh1 , %x
@@ -207,8 +207,8 @@ define <2 x i32> @masked_bit_set_commute(<2 x i32> %px, <2 x i32> %y) {
207
207
; CHECK-LABEL: @masked_bit_set_commute(
208
208
; CHECK-NEXT: [[X:%.*]] = srem <2 x i32> <i32 42, i32 3>, [[PX:%.*]]
209
209
; CHECK-NEXT: [[TMP1:%.*]] = lshr <2 x i32> [[X]], [[Y:%.*]]
210
- ; CHECK-NEXT: [[TMP2 :%.*]] = and <2 x i32> [[TMP1]], <i32 1, i32 1>
211
- ; CHECK-NEXT: ret <2 x i32> [[TMP2 ]]
210
+ ; CHECK-NEXT: [[R :%.*]] = and <2 x i32> [[TMP1]], <i32 1, i32 1>
211
+ ; CHECK-NEXT: ret <2 x i32> [[R ]]
212
212
;
213
213
%x = srem <2 x i32 > <i32 42 , i32 3 >, %px ; thwart complexity-based canonicalization
214
214
%sh1 = shl <2 x i32 > <i32 1 , i32 1 >, %y
@@ -223,8 +223,8 @@ define i32 @masked_bit_clear_commute(i32 %px, i32 %y) {
223
223
; CHECK-NEXT: [[X:%.*]] = srem i32 42, [[PX:%.*]]
224
224
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X]], -1
225
225
; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP1]], [[Y:%.*]]
226
- ; CHECK-NEXT: [[TMP3 :%.*]] = and i32 [[TMP2]], 1
227
- ; CHECK-NEXT: ret i32 [[TMP3 ]]
226
+ ; CHECK-NEXT: [[R :%.*]] = and i32 [[TMP2]], 1
227
+ ; CHECK-NEXT: ret i32 [[R ]]
228
228
;
229
229
%x = srem i32 42 , %px ; thwart complexity-based canonicalization
230
230
%sh1 = shl i32 1 , %y
@@ -239,8 +239,8 @@ define i32 @masked_bit_set_use1(i32 %x, i32 %y) {
239
239
; CHECK-NEXT: [[SH1:%.*]] = shl nuw i32 1, [[Y:%.*]]
240
240
; CHECK-NEXT: call void @use32(i32 [[SH1]])
241
241
; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], [[Y]]
242
- ; CHECK-NEXT: [[TMP2 :%.*]] = and i32 [[TMP1]], 1
243
- ; CHECK-NEXT: ret i32 [[TMP2 ]]
242
+ ; CHECK-NEXT: [[R :%.*]] = and i32 [[TMP1]], 1
243
+ ; CHECK-NEXT: ret i32 [[R ]]
244
244
;
245
245
%sh1 = shl i32 1 , %y
246
246
call void @use32 (i32 %sh1 )
@@ -294,8 +294,8 @@ define i32 @masked_bit_clear_use1(i32 %x, i32 %y) {
294
294
; CHECK-NEXT: call void @use32(i32 [[SH1]])
295
295
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], -1
296
296
; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP1]], [[Y]]
297
- ; CHECK-NEXT: [[TMP3 :%.*]] = and i32 [[TMP2]], 1
298
- ; CHECK-NEXT: ret i32 [[TMP3 ]]
297
+ ; CHECK-NEXT: [[R :%.*]] = and i32 [[TMP2]], 1
298
+ ; CHECK-NEXT: ret i32 [[R ]]
299
299
;
300
300
%sh1 = shl i32 1 , %y
301
301
call void @use32 (i32 %sh1 )
@@ -642,3 +642,50 @@ define i64 @and_trunc_extra_use1_wider_src(i65 %x, i32 %y) {
642
642
%z = zext i32 %a to i64
643
643
ret i64 %z
644
644
}
645
+
646
+ define i16 @zext_icmp_eq0_pow2 (i32 %x ) {
647
+ ; CHECK-LABEL: @zext_icmp_eq0_pow2(
648
+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[X:%.*]] to i16
649
+ ; CHECK-NEXT: [[TMP2:%.*]] = lshr i16 [[TMP1]], 2
650
+ ; CHECK-NEXT: [[TMP3:%.*]] = and i16 [[TMP2]], 1
651
+ ; CHECK-NEXT: [[Z:%.*]] = xor i16 [[TMP3]], 1
652
+ ; CHECK-NEXT: ret i16 [[Z]]
653
+ ;
654
+ %m = and i32 %x , 4
655
+ %i = icmp eq i32 %m , 0
656
+ %z = zext i1 %i to i16
657
+ ret i16 %z
658
+ }
659
+
660
+ define i16 @zext_icmp_eq0_pow2_use1 (i32 %x ) {
661
+ ; CHECK-LABEL: @zext_icmp_eq0_pow2_use1(
662
+ ; CHECK-NEXT: [[M:%.*]] = and i32 [[X:%.*]], 4
663
+ ; CHECK-NEXT: call void @use32(i32 [[M]])
664
+ ; CHECK-NEXT: [[M_LOBIT:%.*]] = lshr exact i32 [[M]], 2
665
+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[M_LOBIT]] to i16
666
+ ; CHECK-NEXT: [[Z:%.*]] = xor i16 [[TMP1]], 1
667
+ ; CHECK-NEXT: ret i16 [[Z]]
668
+ ;
669
+ %m = and i32 %x , 4
670
+ call void @use32 (i32 %m )
671
+ %i = icmp eq i32 %m , 0
672
+ %z = zext i1 %i to i16
673
+ ret i16 %z
674
+ }
675
+
676
+ define i16 @zext_icmp_eq0_pow2_use2 (i32 %x ) {
677
+ ; CHECK-LABEL: @zext_icmp_eq0_pow2_use2(
678
+ ; CHECK-NEXT: [[M:%.*]] = and i32 [[X:%.*]], 4
679
+ ; CHECK-NEXT: [[I:%.*]] = icmp eq i32 [[M]], 0
680
+ ; CHECK-NEXT: call void @use1(i1 [[I]])
681
+ ; CHECK-NEXT: [[M_LOBIT:%.*]] = lshr exact i32 [[M]], 2
682
+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[M_LOBIT]] to i16
683
+ ; CHECK-NEXT: [[Z:%.*]] = xor i16 [[TMP1]], 1
684
+ ; CHECK-NEXT: ret i16 [[Z]]
685
+ ;
686
+ %m = and i32 %x , 4
687
+ %i = icmp eq i32 %m , 0
688
+ call void @use1 (i1 %i )
689
+ %z = zext i1 %i to i16
690
+ ret i16 %z
691
+ }
0 commit comments