1
1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2
2
; RUN: opt < %s -instcombine -S | FileCheck %s
3
3
4
+ declare void @use1 (i1 )
5
+ declare void @use8 (i8 )
6
+
4
7
define i32 @test1 (i32 %A ) {
5
8
; CHECK-LABEL: @test1(
6
9
; CHECK-NEXT: ret i32 [[A:%.*]]
@@ -12,8 +15,8 @@ define i32 @test1(i32 %A) {
12
15
13
16
define i1 @invert_icmp (i32 %A , i32 %B ) {
14
17
; CHECK-LABEL: @invert_icmp(
15
- ; CHECK-NEXT: [[CMP :%.*]] = icmp sgt i32 [[A:%.*]], [[B:%.*]]
16
- ; CHECK-NEXT: ret i1 [[CMP ]]
18
+ ; CHECK-NEXT: [[CMP_NOT :%.*]] = icmp sgt i32 [[A:%.*]], [[B:%.*]]
19
+ ; CHECK-NEXT: ret i1 [[CMP_NOT ]]
17
20
;
18
21
%cmp = icmp sle i32 %A , %B
19
22
%not = xor i1 %cmp , true
@@ -78,8 +81,8 @@ define <2 x i1> @not_cmp_constant_vector(<2 x i32> %a) {
78
81
79
82
define <2 x i1 > @test7 (<2 x i32 > %A , <2 x i32 > %B ) {
80
83
; CHECK-LABEL: @test7(
81
- ; CHECK-NEXT: [[COND :%.*]] = icmp sgt <2 x i32> [[A:%.*]], [[B:%.*]]
82
- ; CHECK-NEXT: ret <2 x i1> [[COND ]]
84
+ ; CHECK-NEXT: [[COND_NOT :%.*]] = icmp sgt <2 x i32> [[A:%.*]], [[B:%.*]]
85
+ ; CHECK-NEXT: ret <2 x i1> [[COND_NOT ]]
83
86
;
84
87
%cond = icmp sle <2 x i32 > %A , %B
85
88
%Ret = xor <2 x i1 > %cond , <i1 true , i1 true >
@@ -88,8 +91,8 @@ define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {
88
91
89
92
define i32 @not_ashr_not (i32 %A , i32 %B ) {
90
93
; CHECK-LABEL: @not_ashr_not(
91
- ; CHECK-NEXT: [[NOT2 :%.*]] = ashr i32 [[A:%.*]], [[B:%.*]]
92
- ; CHECK-NEXT: ret i32 [[NOT2 ]]
94
+ ; CHECK-NEXT: [[NOT1_NOT :%.*]] = ashr i32 [[A:%.*]], [[B:%.*]]
95
+ ; CHECK-NEXT: ret i32 [[NOT1_NOT ]]
93
96
;
94
97
%not1 = xor i32 %A , -1
95
98
%ashr = ashr i32 %not1 , %B
@@ -265,8 +268,6 @@ define i1 @not_select_cmp_cmp(i32 %x, i32 %y, float %z, float %w, i1 %cond) {
265
268
ret i1 %not
266
269
}
267
270
268
- declare void @use1 (i1 )
269
-
270
271
; TODO: Missed canonicalization - hoist 'not'?
271
272
272
273
define i1 @not_select_cmp_cmp_extra_use1 (i32 %x , i32 %y , float %z , float %w , i1 %cond ) {
@@ -404,3 +405,61 @@ define i1 @not_select_cmpf_extra_use(i1 %x, i32 %z, i32 %w, i1 %cond) {
404
405
%not = xor i1 %sel , true
405
406
ret i1 %not
406
407
}
408
+
409
+ define i8 @not_or_neg (i8 %x , i8 %y ) {
410
+ ; CHECK-LABEL: @not_or_neg(
411
+ ; CHECK-NEXT: [[S:%.*]] = sub i8 0, [[Y:%.*]]
412
+ ; CHECK-NEXT: [[O:%.*]] = or i8 [[S]], [[X:%.*]]
413
+ ; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[O]], -1
414
+ ; CHECK-NEXT: ret i8 [[NOT]]
415
+ ;
416
+ %s = sub i8 0 , %y
417
+ %o = or i8 %s , %x
418
+ %not = xor i8 %o , -1
419
+ ret i8 %not
420
+ }
421
+
422
+ define <3 x i5 > @not_or_neg_commute_vec (<3 x i5 > %x , <3 x i5 > %p ) {
423
+ ; CHECK-LABEL: @not_or_neg_commute_vec(
424
+ ; CHECK-NEXT: [[Y:%.*]] = mul <3 x i5> [[P:%.*]], <i5 1, i5 2, i5 3>
425
+ ; CHECK-NEXT: [[S:%.*]] = sub <3 x i5> <i5 0, i5 0, i5 undef>, [[X:%.*]]
426
+ ; CHECK-NEXT: [[O:%.*]] = or <3 x i5> [[Y]], [[S]]
427
+ ; CHECK-NEXT: [[NOT:%.*]] = xor <3 x i5> [[O]], <i5 -1, i5 undef, i5 -1>
428
+ ; CHECK-NEXT: ret <3 x i5> [[NOT]]
429
+ ;
430
+ %y = mul <3 x i5 > %p , <i5 1 , i5 2 , i5 3 > ; thwart complexity-based-canonicalization
431
+ %s = sub <3 x i5 > <i5 0 , i5 0 , i5 undef >, %x
432
+ %o = or <3 x i5 > %y , %s
433
+ %not = xor <3 x i5 > %o , <i5 -1 , i5 undef , i5 -1 >
434
+ ret <3 x i5 > %not
435
+ }
436
+
437
+ define i8 @not_or_neg_use1 (i8 %x , i8 %y ) {
438
+ ; CHECK-LABEL: @not_or_neg_use1(
439
+ ; CHECK-NEXT: [[S:%.*]] = sub i8 0, [[Y:%.*]]
440
+ ; CHECK-NEXT: call void @use8(i8 [[S]])
441
+ ; CHECK-NEXT: [[O:%.*]] = or i8 [[S]], [[X:%.*]]
442
+ ; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[O]], -1
443
+ ; CHECK-NEXT: ret i8 [[NOT]]
444
+ ;
445
+ %s = sub i8 0 , %y
446
+ call void @use8 (i8 %s )
447
+ %o = or i8 %s , %x
448
+ %not = xor i8 %o , -1
449
+ ret i8 %not
450
+ }
451
+
452
+ define i8 @not_or_neg_use2 (i8 %x , i8 %y ) {
453
+ ; CHECK-LABEL: @not_or_neg_use2(
454
+ ; CHECK-NEXT: [[S:%.*]] = sub i8 0, [[Y:%.*]]
455
+ ; CHECK-NEXT: [[O:%.*]] = or i8 [[S]], [[X:%.*]]
456
+ ; CHECK-NEXT: call void @use8(i8 [[O]])
457
+ ; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[O]], -1
458
+ ; CHECK-NEXT: ret i8 [[NOT]]
459
+ ;
460
+ %s = sub i8 0 , %y
461
+ %o = or i8 %s , %x
462
+ call void @use8 (i8 %o )
463
+ %not = xor i8 %o , -1
464
+ ret i8 %not
465
+ }
0 commit comments