1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -S -o - %s | FileCheck %s
4 declare void @use.i8(i8)
5 declare void @use.v2i8(<2 x i8>)
6 define i1 @src_add_eq_p2(i8 %x, i8 %yy) {
7 ; CHECK-LABEL: @src_add_eq_p2(
8 ; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]]
9 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY]], [[NY]]
10 ; CHECK-NEXT: [[X1:%.*]] = add i8 [[Y]], [[X:%.*]]
11 ; CHECK-NEXT: call void @use.i8(i8 [[X1]])
12 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X]], [[Y]]
13 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[TMP1]], 0
14 ; CHECK-NEXT: ret i1 [[R]]
19 call void @use.i8(i8 %x1)
21 %r = icmp eq i8 %v, %y
25 define i1 @src_add_eq_p2_fail_multiuse(i8 %x, i8 %yy) {
26 ; CHECK-LABEL: @src_add_eq_p2_fail_multiuse(
27 ; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]]
28 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY]], [[NY]]
29 ; CHECK-NEXT: [[X1:%.*]] = add i8 [[X:%.*]], [[Y]]
30 ; CHECK-NEXT: call void @use.i8(i8 [[X1]])
31 ; CHECK-NEXT: [[V:%.*]] = and i8 [[X1]], [[Y]]
32 ; CHECK-NEXT: call void @use.i8(i8 [[V]])
33 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], [[Y]]
34 ; CHECK-NEXT: ret i1 [[R]]
39 call void @use.i8(i8 %x1)
41 call void @use.i8(i8 %v)
42 %r = icmp eq i8 %v, %y
46 define i1 @src_xor_ne_zero(i8 %x, i8 %yy) {
47 ; CHECK-LABEL: @src_xor_ne_zero(
48 ; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]]
49 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY]], [[NY]]
50 ; CHECK-NEXT: [[X1:%.*]] = xor i8 [[X:%.*]], [[Y]]
51 ; CHECK-NEXT: call void @use.i8(i8 [[X1]])
52 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X]], [[Y]]
53 ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[TMP1]], [[Y]]
54 ; CHECK-NEXT: ret i1 [[R]]
59 call void @use.i8(i8 %x1)
65 define i1 @src_xor_ne_zero_fail_different_p2(i8 %x, i8 %yy) {
66 ; CHECK-LABEL: @src_xor_ne_zero_fail_different_p2(
67 ; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]]
68 ; CHECK-NEXT: [[Y:%.*]] = and i8 [[YY]], [[NY]]
69 ; CHECK-NEXT: [[Y2:%.*]] = shl i8 [[Y]], 1
70 ; CHECK-NEXT: [[X1:%.*]] = xor i8 [[X:%.*]], [[Y]]
71 ; CHECK-NEXT: call void @use.i8(i8 [[X1]])
72 ; CHECK-NEXT: [[V:%.*]] = and i8 [[X1]], [[Y2]]
73 ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[V]], 0
74 ; CHECK-NEXT: ret i1 [[R]]
80 call void @use.i8(i8 %x1)
86 define <2 x i1> @src_sub_ne_p2(<2 x i8> %x, <2 x i8> %yy) {
87 ; CHECK-LABEL: @src_sub_ne_p2(
88 ; CHECK-NEXT: [[NY:%.*]] = sub <2 x i8> zeroinitializer, [[YY:%.*]]
89 ; CHECK-NEXT: [[Y:%.*]] = and <2 x i8> [[YY]], [[NY]]
90 ; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[X:%.*]], [[Y]]
91 ; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]])
92 ; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i8> [[X]], [[Y]]
93 ; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[TMP1]], zeroinitializer
94 ; CHECK-NEXT: ret <2 x i1> [[R]]
96 %ny = sub <2 x i8> zeroinitializer, %yy
97 %y = and <2 x i8> %ny, %yy
98 %x1 = sub <2 x i8> %x, %y
99 call void @use.v2i8(<2 x i8> %x1)
100 %v = and <2 x i8> %x1, %y
101 %r = icmp ne <2 x i8> %v, %y
105 define <2 x i1> @src_sub_eq_zero(<2 x i8> %x, <2 x i8> %yy) {
106 ; CHECK-LABEL: @src_sub_eq_zero(
107 ; CHECK-NEXT: [[Y:%.*]] = shl <2 x i8> <i8 1, i8 2>, [[YY:%.*]]
108 ; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[X:%.*]], [[Y]]
109 ; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]])
110 ; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i8> [[X]], [[Y]]
111 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[TMP1]], [[Y]]
112 ; CHECK-NEXT: ret <2 x i1> [[R]]
114 %y = shl <2 x i8> <i8 1, i8 2>, %yy
115 %x1 = sub <2 x i8> %x, %y
116 call void @use.v2i8(<2 x i8> %x1)
117 %v = and <2 x i8> %x1, %y
118 %r = icmp eq <2 x i8> %v, zeroinitializer
122 define <2 x i1> @src_sub_eq_zero_fail_commuted(<2 x i8> %x, <2 x i8> %yy) {
123 ; CHECK-LABEL: @src_sub_eq_zero_fail_commuted(
124 ; CHECK-NEXT: [[Y:%.*]] = shl <2 x i8> <i8 1, i8 2>, [[YY:%.*]]
125 ; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[Y]], [[X:%.*]]
126 ; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]])
127 ; CHECK-NEXT: [[V:%.*]] = and <2 x i8> [[X1]], [[Y]]
128 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[V]], zeroinitializer
129 ; CHECK-NEXT: ret <2 x i1> [[R]]
131 %y = shl <2 x i8> <i8 1, i8 2>, %yy
132 %x1 = sub <2 x i8> %y, %x
133 call void @use.v2i8(<2 x i8> %x1)
134 %v = and <2 x i8> %x1, %y
135 %r = icmp eq <2 x i8> %v, zeroinitializer
139 define <2 x i1> @src_sub_eq_zero_fail_non_p2(<2 x i8> %x, <2 x i8> %yy) {
140 ; CHECK-LABEL: @src_sub_eq_zero_fail_non_p2(
141 ; CHECK-NEXT: [[Y:%.*]] = shl <2 x i8> <i8 1, i8 3>, [[YY:%.*]]
142 ; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[X:%.*]], [[Y]]
143 ; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]])
144 ; CHECK-NEXT: [[V:%.*]] = and <2 x i8> [[X1]], [[Y]]
145 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[V]], zeroinitializer
146 ; CHECK-NEXT: ret <2 x i1> [[R]]
148 %y = shl <2 x i8> <i8 1, i8 3>, %yy
149 %x1 = sub <2 x i8> %x, %y
150 call void @use.v2i8(<2 x i8> %x1)
151 %v = and <2 x i8> %x1, %y
152 %r = icmp eq <2 x i8> %v, zeroinitializer