1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt %s -instcombine -S | FileCheck %s
5 ; ((%x * %y) u/ %x) != %y
7 ; @llvm.umul.with.overflow(%x, %y) + extractvalue
9 define i1 @t0_basic(i8 %x, i8 %y) {
10 ; CHECK-LABEL: @t0_basic(
11 ; CHECK-NEXT: [[UMUL:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
12 ; CHECK-NEXT: [[UMUL_OV:%.*]] = extractvalue { i8, i1 } [[UMUL]], 1
13 ; CHECK-NEXT: ret i1 [[UMUL_OV]]
17 %r = icmp ne i8 %t1, %y
21 define <2 x i1> @t1_vec(<2 x i8> %x, <2 x i8> %y) {
22 ; CHECK-LABEL: @t1_vec(
23 ; CHECK-NEXT: [[UMUL:%.*]] = call { <2 x i8>, <2 x i1> } @llvm.umul.with.overflow.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])
24 ; CHECK-NEXT: [[UMUL_OV:%.*]] = extractvalue { <2 x i8>, <2 x i1> } [[UMUL]], 1
25 ; CHECK-NEXT: ret <2 x i1> [[UMUL_OV]]
27 %t0 = mul <2 x i8> %x, %y
28 %t1 = udiv <2 x i8> %t0, %x
29 %r = icmp ne <2 x i8> %t1, %y
35 define i1 @t2_commutative(i8 %x) {
36 ; CHECK-LABEL: @t2_commutative(
37 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
38 ; CHECK-NEXT: [[UMUL:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y]])
39 ; CHECK-NEXT: [[UMUL_OV:%.*]] = extractvalue { i8, i1 } [[UMUL]], 1
40 ; CHECK-NEXT: ret i1 [[UMUL_OV]]
43 %t0 = mul i8 %y, %x ; swapped
45 %r = icmp ne i8 %t1, %y
49 define i1 @t3_commutative(i8 %x) {
50 ; CHECK-LABEL: @t3_commutative(
51 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
52 ; CHECK-NEXT: [[UMUL:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y]])
53 ; CHECK-NEXT: [[UMUL_OV:%.*]] = extractvalue { i8, i1 } [[UMUL]], 1
54 ; CHECK-NEXT: ret i1 [[UMUL_OV]]
57 %t0 = mul i8 %y, %x ; swapped
59 %r = icmp ne i8 %t1, %y
63 define i1 @t4_commutative(i8 %x) {
64 ; CHECK-LABEL: @t4_commutative(
65 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
66 ; CHECK-NEXT: [[UMUL:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y]])
67 ; CHECK-NEXT: [[UMUL_OV:%.*]] = extractvalue { i8, i1 } [[UMUL]], 1
68 ; CHECK-NEXT: ret i1 [[UMUL_OV]]
71 %t0 = mul i8 %y, %x ; swapped
73 %r = icmp ne i8 %y, %t1 ; swapped
79 declare void @use8(i8)
81 define i1 @t5_extrause0(i8 %x, i8 %y) {
82 ; CHECK-LABEL: @t5_extrause0(
83 ; CHECK-NEXT: [[UMUL:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
84 ; CHECK-NEXT: [[UMUL_VAL:%.*]] = extractvalue { i8, i1 } [[UMUL]], 0
85 ; CHECK-NEXT: [[UMUL_OV:%.*]] = extractvalue { i8, i1 } [[UMUL]], 1
86 ; CHECK-NEXT: call void @use8(i8 [[UMUL_VAL]])
87 ; CHECK-NEXT: ret i1 [[UMUL_OV]]
90 call void @use8(i8 %t0)
92 %r = icmp ne i8 %t1, %y
96 define i1 @t6_extrause1(i8 %x, i8 %y) {
97 ; CHECK-LABEL: @t6_extrause1(
98 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
99 ; CHECK-NEXT: [[T1:%.*]] = udiv i8 [[T0]], [[X]]
100 ; CHECK-NEXT: call void @use8(i8 [[T1]])
101 ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[T1]], [[Y]]
102 ; CHECK-NEXT: ret i1 [[R]]
105 %t1 = udiv i8 %t0, %x
106 call void @use8(i8 %t1)
107 %r = icmp ne i8 %t1, %y
111 define i1 @t7_extrause2(i8 %x, i8 %y) {
112 ; CHECK-LABEL: @t7_extrause2(
113 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
114 ; CHECK-NEXT: call void @use8(i8 [[T0]])
115 ; CHECK-NEXT: [[T1:%.*]] = udiv i8 [[T0]], [[X]]
116 ; CHECK-NEXT: call void @use8(i8 [[T1]])
117 ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[T1]], [[Y]]
118 ; CHECK-NEXT: ret i1 [[R]]
121 call void @use8(i8 %t0)
122 %t1 = udiv i8 %t0, %x
123 call void @use8(i8 %t1)
124 %r = icmp ne i8 %t1, %y
130 define i1 @n8_different_x(i8 %x0, i8 %x1, i8 %y) {
131 ; CHECK-LABEL: @n8_different_x(
132 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X0:%.*]], [[Y:%.*]]
133 ; CHECK-NEXT: [[T1:%.*]] = udiv i8 [[T0]], [[X1:%.*]]
134 ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[T1]], [[Y]]
135 ; CHECK-NEXT: ret i1 [[R]]
138 %t1 = udiv i8 %t0, %x1
139 %r = icmp ne i8 %t1, %y
143 define i1 @n9_different_y(i8 %x, i8 %y0, i8 %y1) {
144 ; CHECK-LABEL: @n9_different_y(
145 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y0:%.*]]
146 ; CHECK-NEXT: [[T1:%.*]] = udiv i8 [[T0]], [[X]]
147 ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[T1]], [[Y1:%.*]]
148 ; CHECK-NEXT: ret i1 [[R]]
151 %t1 = udiv i8 %t0, %x
152 %r = icmp ne i8 %t1, %y1
156 define i1 @n10_wrong_pred(i8 %x, i8 %y) {
157 ; CHECK-LABEL: @n10_wrong_pred(
158 ; CHECK-NEXT: [[T0:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
159 ; CHECK-NEXT: [[T1:%.*]] = udiv i8 [[T0]], [[X]]
160 ; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T1]], [[Y]]
161 ; CHECK-NEXT: ret i1 [[R]]
164 %t1 = udiv i8 %t0, %x
165 %r = icmp ugt i8 %t1, %y