1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
9 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
10 ; CHECK-NEXT: ret i1 [[CMP]]
12 %neg_x = sub nsw i8 0, %x
13 %cmp = icmp sgt i8 %neg_x, %x
17 define i1 @t0_commutative() {
18 ; CHECK-LABEL: @t0_commutative(
19 ; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
20 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], 0
21 ; CHECK-NEXT: ret i1 [[CMP]]
24 %neg_x = sub nsw i8 0, %x
25 %cmp = icmp slt i8 %x, %neg_x
29 define i1 @t0_extrause(i8 %x) {
30 ; CHECK-LABEL: @t0_extrause(
31 ; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]]
32 ; CHECK-NEXT: call void @use8(i8 [[NEG_X]])
33 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], 0
34 ; CHECK-NEXT: ret i1 [[CMP]]
36 %neg_x = sub nsw i8 0, %x
37 call void @use8(i8 %neg_x)
38 %cmp = icmp sgt i8 %neg_x, %x
42 define i1 @t1(i8 %x) {
44 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
45 ; CHECK-NEXT: ret i1 [[CMP]]
47 %neg_x = sub nsw i8 0, %x
48 %cmp = icmp sge i8 %neg_x, %x
52 define i1 @t2(i8 %x) {
54 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 0
55 ; CHECK-NEXT: ret i1 [[CMP]]
57 %neg_x = sub nsw i8 0, %x
58 %cmp = icmp slt i8 %neg_x, %x
62 define i1 @t3(i8 %x) {
64 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
65 ; CHECK-NEXT: ret i1 [[CMP]]
67 %neg_x = sub nsw i8 0, %x
68 %cmp = icmp sle i8 %neg_x, %x
72 define i1 @t4(i8 %x) {
74 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 0
75 ; CHECK-NEXT: ret i1 [[CMP]]
77 %neg_x = sub nsw i8 0, %x
78 %cmp = icmp ugt i8 %neg_x, %x
82 define i1 @t5(i8 %x) {
84 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
85 ; CHECK-NEXT: ret i1 [[CMP]]
87 %neg_x = sub nsw i8 0, %x
88 %cmp = icmp uge i8 %neg_x, %x
92 define i1 @t6(i8 %x) {
94 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
95 ; CHECK-NEXT: ret i1 [[CMP]]
97 %neg_x = sub nsw i8 0, %x
98 %cmp = icmp ult i8 %neg_x, %x
102 define i1 @t7(i8 %x) {
104 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
105 ; CHECK-NEXT: ret i1 [[CMP]]
107 %neg_x = sub nsw i8 0, %x
108 %cmp = icmp ule i8 %neg_x, %x
112 define i1 @t8(i8 %x) {
114 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
115 ; CHECK-NEXT: ret i1 [[CMP]]
117 %neg_x = sub nsw i8 0, %x
118 %cmp = icmp eq i8 %neg_x, %x
122 define i1 @t9(i8 %x) {
124 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 0
125 ; CHECK-NEXT: ret i1 [[CMP]]
127 %neg_x = sub nsw i8 0, %x
128 %cmp = icmp ne i8 %neg_x, %x
132 define i1 @n10(i8 %x) {
134 ; CHECK-NEXT: [[NEG_X:%.*]] = sub i8 0, [[X:%.*]]
135 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], [[NEG_X]]
136 ; CHECK-NEXT: ret i1 [[CMP]]
138 %neg_x = sub i8 0, %x ; not nsw
139 %cmp = icmp sgt i8 %neg_x, %x
143 define i1 @n11(i8 %x) {
145 ; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 1, [[X:%.*]]
146 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]]
147 ; CHECK-NEXT: ret i1 [[CMP]]
149 %neg_x = sub nsw i8 1, %x ; not negation
150 %cmp = icmp sgt i8 %neg_x, %x
154 define i1 @n12(i8 %x1, i8 %x2) {
156 ; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X1:%.*]]
157 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X2:%.*]], [[NEG_X]]
158 ; CHECK-NEXT: ret i1 [[CMP]]
160 %neg_x = sub nsw i8 0, %x1 ; not %x2
161 %cmp = icmp sgt i8 %neg_x, %x2 ; not %x1