cmp-x-vs-neg-x.ll
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare i8 @gen8()
declare void @use8(i8)
define i1 @t0(i8 %x) {
; CHECK-LABEL: @t0(
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp sgt i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t0_commutative() {
; CHECK-LABEL: @t0_commutative(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%x = call i8 @gen8()
%neg_x = sub nsw i8 0, %x
%cmp = icmp slt i8 %x, %neg_x
ret i1 %cmp
}
define i1 @t0_extrause(i8 %x) {
; CHECK-LABEL: @t0_extrause(
; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[NEG_X]])
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
call void @use8(i8 %neg_x)
%cmp = icmp sgt i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t1(i8 %x) {
; CHECK-LABEL: @t1(
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp sge i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t2(i8 %x) {
; CHECK-LABEL: @t2(
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp slt i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t3(i8 %x) {
; CHECK-LABEL: @t3(
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp sle i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t4(i8 %x) {
; CHECK-LABEL: @t4(
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp ugt i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t5(i8 %x) {
; CHECK-LABEL: @t5(
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp uge i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t6(i8 %x) {
; CHECK-LABEL: @t6(
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp ult i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t7(i8 %x) {
; CHECK-LABEL: @t7(
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp ule i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t8(i8 %x) {
; CHECK-LABEL: @t8(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp eq i8 %neg_x, %x
ret i1 %cmp
}
define i1 @t9(i8 %x) {
; CHECK-LABEL: @t9(
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 0
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x
%cmp = icmp ne i8 %neg_x, %x
ret i1 %cmp
}
define i1 @n10(i8 %x) {
; CHECK-LABEL: @n10(
; CHECK-NEXT: [[NEG_X:%.*]] = sub i8 0, [[X:%.*]]
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub i8 0, %x ; not nsw
%cmp = icmp sgt i8 %neg_x, %x
ret i1 %cmp
}
define i1 @n11(i8 %x) {
; CHECK-LABEL: @n11(
; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 1, [[X:%.*]]
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 1, %x ; not negation
%cmp = icmp sgt i8 %neg_x, %x
ret i1 %cmp
}
define i1 @n12(i8 %x1, i8 %x2) {
; CHECK-LABEL: @n12(
; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X1:%.*]]
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X2:%.*]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%neg_x = sub nsw i8 0, %x1 ; not %x2
%cmp = icmp sgt i8 %neg_x, %x2 ; not %x1
ret i1 %cmp
}