1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
5 ; ((%x * %y) s/ %x) == %y
7 ; @llvm.smul.with.overflow(%x, %y) + extractvalue + not
9 define i1 @t0_basic(i8 %x, i8 %y) {
10 ; CHECK-LABEL: @t0_basic(
11 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
12 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
13 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
14 ; CHECK-NEXT: ret i1 [[R]]
18 %r = icmp eq i8 %t1, %y
22 define <2 x i1> @t1_vec(<2 x i8> %x, <2 x i8> %y) {
23 ; CHECK-LABEL: @t1_vec(
24 ; CHECK-NEXT: [[T0:%.*]] = mul <2 x i8> [[X:%.*]], [[Y:%.*]]
25 ; CHECK-NEXT: [[T1:%.*]] = sdiv <2 x i8> [[T0]], [[X]]
26 ; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[T1]], [[Y]]
27 ; CHECK-NEXT: ret <2 x i1> [[R]]
29 %t0 = mul <2 x i8> %x, %y
30 %t1 = sdiv <2 x i8> %t0, %x
31 %r = icmp eq <2 x i8> %t1, %y
37 define i1 @t2_commutative(i8 %x) {
38 ; CHECK-LABEL: @t2_commutative(
39 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
40 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[Y]], [[X:%.*]]
41 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
42 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
43 ; CHECK-NEXT: ret i1 [[R]]
46 %t0 = mul i8 %y, %x ; swapped
48 %r = icmp eq i8 %t1, %y
52 define i1 @t3_commutative(i8 %x) {
53 ; CHECK-LABEL: @t3_commutative(
54 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
55 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[Y]], [[X:%.*]]
56 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
57 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
58 ; CHECK-NEXT: ret i1 [[R]]
61 %t0 = mul i8 %y, %x ; swapped
63 %r = icmp eq i8 %t1, %y
67 define i1 @t4_commutative(i8 %x) {
68 ; CHECK-LABEL: @t4_commutative(
69 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
70 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[Y]], [[X:%.*]]
71 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
72 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[Y]], [[T1]]
73 ; CHECK-NEXT: ret i1 [[R]]
76 %t0 = mul i8 %y, %x ; swapped
78 %r = icmp eq i8 %y, %t1 ; swapped
84 declare void @use8(i8)
86 define i1 @t5_extrause0(i8 %x, i8 %y) {
87 ; CHECK-LABEL: @t5_extrause0(
88 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
89 ; CHECK-NEXT: call void @use8(i8 [[T0]])
90 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
91 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
92 ; CHECK-NEXT: ret i1 [[R]]
95 call void @use8(i8 %t0)
97 %r = icmp eq i8 %t1, %y
101 define i1 @t6_extrause1(i8 %x, i8 %y) {
102 ; CHECK-LABEL: @t6_extrause1(
103 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
104 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
105 ; CHECK-NEXT: call void @use8(i8 [[T1]])
106 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
107 ; CHECK-NEXT: ret i1 [[R]]
110 %t1 = sdiv i8 %t0, %x
111 call void @use8(i8 %t1)
112 %r = icmp eq i8 %t1, %y
116 define i1 @t7_extrause2(i8 %x, i8 %y) {
117 ; CHECK-LABEL: @t7_extrause2(
118 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
119 ; CHECK-NEXT: call void @use8(i8 [[T0]])
120 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
121 ; CHECK-NEXT: call void @use8(i8 [[T1]])
122 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
123 ; CHECK-NEXT: ret i1 [[R]]
126 call void @use8(i8 %t0)
127 %t1 = sdiv i8 %t0, %x
128 call void @use8(i8 %t1)
129 %r = icmp eq i8 %t1, %y
135 define i1 @n8_different_x(i8 %x0, i8 %x1, i8 %y) {
136 ; CHECK-LABEL: @n8_different_x(
137 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X0:%.*]], [[Y:%.*]]
138 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X1:%.*]]
139 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y]]
140 ; CHECK-NEXT: ret i1 [[R]]
143 %t1 = sdiv i8 %t0, %x1
144 %r = icmp eq i8 %t1, %y
148 define i1 @n9_different_y(i8 %x, i8 %y0, i8 %y1) {
149 ; CHECK-LABEL: @n9_different_y(
150 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y0:%.*]]
151 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
152 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1]], [[Y1:%.*]]
153 ; CHECK-NEXT: ret i1 [[R]]
156 %t1 = sdiv i8 %t0, %x
157 %r = icmp eq i8 %t1, %y1
161 define i1 @n10_wrong_pred(i8 %x, i8 %y) {
162 ; CHECK-LABEL: @n10_wrong_pred(
163 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
164 ; CHECK-NEXT: [[T1:%.*]] = sdiv i8 [[T0]], [[X]]
165 ; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T1]], [[Y]]
166 ; CHECK-NEXT: ret i1 [[R]]
169 %t1 = sdiv i8 %t0, %x
170 %r = icmp ult i8 %t1, %y