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
- define i32 @func1 (i32 %a , i32 %b ) {
5
- ; CHECK-LABEL: @func1(
4
+ ; ((b | a) & C1) | (b & C2) -> (a & C1) | b iff C1 == ~C2
5
+
6
+ define i32 @or_and_not_constant_commute0 (i32 %a , i32 %b ) {
7
+ ; CHECK-LABEL: @or_and_not_constant_commute0(
6
8
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[A:%.*]], 1
7
9
; CHECK-NEXT: [[T3:%.*]] = or i32 [[TMP1]], [[B:%.*]]
8
10
; CHECK-NEXT: ret i32 [[T3]]
@@ -14,8 +16,8 @@ define i32 @func1(i32 %a, i32 %b) {
14
16
ret i32 %t3
15
17
}
16
18
17
- define i32 @func2 (i32 %a , i32 %b ) {
18
- ; CHECK-LABEL: @func2 (
19
+ define i32 @or_and_not_constant_commute1 (i32 %a , i32 %b ) {
20
+ ; CHECK-LABEL: @or_and_not_constant_commute1 (
19
21
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[A:%.*]], 1
20
22
; CHECK-NEXT: [[T3:%.*]] = or i32 [[TMP1]], [[B:%.*]]
21
23
; CHECK-NEXT: ret i32 [[T3]]
@@ -27,8 +29,8 @@ define i32 @func2(i32 %a, i32 %b) {
27
29
ret i32 %t3
28
30
}
29
31
30
- define i32 @func3 (i32 %a , i32 %b ) {
31
- ; CHECK-LABEL: @func3 (
32
+ define i32 @or_and_not_constant_commute2 (i32 %a , i32 %b ) {
33
+ ; CHECK-LABEL: @or_and_not_constant_commute2 (
32
34
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[A:%.*]], 1
33
35
; CHECK-NEXT: [[T3:%.*]] = or i32 [[TMP1]], [[B:%.*]]
34
36
; CHECK-NEXT: ret i32 [[T3]]
@@ -40,8 +42,8 @@ define i32 @func3(i32 %a, i32 %b) {
40
42
ret i32 %t3
41
43
}
42
44
43
- define i32 @func4 (i32 %a , i32 %b ) {
44
- ; CHECK-LABEL: @func4 (
45
+ define i32 @or_and_not_constant_commute3 (i32 %a , i32 %b ) {
46
+ ; CHECK-LABEL: @or_and_not_constant_commute3 (
45
47
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[A:%.*]], 1
46
48
; CHECK-NEXT: [[T3:%.*]] = or i32 [[TMP1]], [[B:%.*]]
47
49
; CHECK-NEXT: ret i32 [[T3]]
@@ -53,6 +55,21 @@ define i32 @func4(i32 %a, i32 %b) {
53
55
ret i32 %t3
54
56
}
55
57
58
+ define <2 x i7 > @or_and_not_constant_commute0_splat (<2 x i7 > %a , <2 x i7 > %b ) {
59
+ ; CHECK-LABEL: @or_and_not_constant_commute0_splat(
60
+ ; CHECK-NEXT: [[T:%.*]] = or <2 x i7> [[B:%.*]], [[A:%.*]]
61
+ ; CHECK-NEXT: [[T1:%.*]] = and <2 x i7> [[T]], <i7 42, i7 42>
62
+ ; CHECK-NEXT: [[T2:%.*]] = and <2 x i7> [[B]], <i7 -43, i7 -43>
63
+ ; CHECK-NEXT: [[T3:%.*]] = or <2 x i7> [[T1]], [[T2]]
64
+ ; CHECK-NEXT: ret <2 x i7> [[T3]]
65
+ ;
66
+ %t = or <2 x i7 > %b , %a
67
+ %t1 = and <2 x i7 > %t , <i7 42 , i7 42 >
68
+ %t2 = and <2 x i7 > %b , <i7 -43 , i7 -43 >
69
+ %t3 = or <2 x i7 > %t1 , %t2
70
+ ret <2 x i7 > %t3
71
+ }
72
+
56
73
; Check variants of:
57
74
; and ({x}or X, Y), C --> {x}or X, (and Y, C)
58
75
; ...in the following 5 tests.
0 commit comments