logic-of-fcmps.ll
4.86 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
; RUN: opt < %s -instsimplify -S | FileCheck %s
; Cycle through commuted variants where one operand of fcmp ord/uno is
; known not-a-NAN and the other is repeated in the logically-connected fcmp.
define i1 @ord1(float %x, float %y) {
; CHECK-LABEL: @ord1(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp ord float %x, %y
; CHECK-NEXT: ret i1 [[CMP2]]
;
%cmp1 = fcmp ord float 0.0, %x
%cmp2 = fcmp ord float %x, %y
%r = and i1 %cmp1, %cmp2
ret i1 %r
}
define i1 @ord2(double %x, double %y) {
; CHECK-LABEL: @ord2(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp ord double %y, %x
; CHECK-NEXT: ret i1 [[CMP2]]
;
%cmp1 = fcmp ord double 42.0, %x
%cmp2 = fcmp ord double %y, %x
%r = and i1 %cmp1, %cmp2
ret i1 %r
}
define <2 x i1> @ord3(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @ord3(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp ord <2 x float> %x, %y
; CHECK-NEXT: ret <2 x i1> [[CMP2]]
;
%cmp1 = fcmp ord <2 x float> %x, zeroinitializer
%cmp2 = fcmp ord <2 x float> %x, %y
%r = and <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define <2 x i1> @ord4(<2 x double> %x, <2 x double> %y) {
; CHECK-LABEL: @ord4(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp ord <2 x double> %y, %x
; CHECK-NEXT: ret <2 x i1> [[CMP2]]
;
%cmp1 = fcmp ord <2 x double> %x, <double 42.0, double 42.0>
%cmp2 = fcmp ord <2 x double> %y, %x
%r = and <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define i1 @ord5(float %x, float %y) {
; CHECK-LABEL: @ord5(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord float %x, %y
; CHECK-NEXT: ret i1 [[CMP1]]
;
%nnan = fdiv nnan float %x, %y
%cmp1 = fcmp ord float %x, %y
%cmp2 = fcmp ord float %nnan, %x
%r = and i1 %cmp1, %cmp2
ret i1 %r
}
define i1 @ord6(double %x, double %y) {
; CHECK-LABEL: @ord6(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord double %y, %x
; CHECK-NEXT: ret i1 [[CMP1]]
;
%cmp1 = fcmp ord double %y, %x
%cmp2 = fcmp ord double 42.0, %x
%r = and i1 %cmp1, %cmp2
ret i1 %r
}
define <2 x i1> @ord7(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @ord7(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord <2 x float> %x, %y
; CHECK-NEXT: ret <2 x i1> [[CMP1]]
;
%cmp1 = fcmp ord <2 x float> %x, %y
%cmp2 = fcmp ord <2 x float> %x, zeroinitializer
%r = and <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define <2 x i1> @ord8(<2 x double> %x, <2 x double> %y) {
; CHECK-LABEL: @ord8(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp ord <2 x double> %y, %x
; CHECK-NEXT: ret <2 x i1> [[CMP1]]
;
%cmp1 = fcmp ord <2 x double> %y, %x
%cmp2 = fcmp ord <2 x double> %x, <double 0.0, double 42.0>
%r = and <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define i1 @uno1(float %x, float %y) {
; CHECK-LABEL: @uno1(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp uno float %x, %y
; CHECK-NEXT: ret i1 [[CMP2]]
;
%cmp1 = fcmp uno float 0.0, %x
%cmp2 = fcmp uno float %x, %y
%r = or i1 %cmp1, %cmp2
ret i1 %r
}
define i1 @uno2(double %x, double %y) {
; CHECK-LABEL: @uno2(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp uno double %y, %x
; CHECK-NEXT: ret i1 [[CMP2]]
;
%cmp1 = fcmp uno double 42.0, %x
%cmp2 = fcmp uno double %y, %x
%r = or i1 %cmp1, %cmp2
ret i1 %r
}
define <2 x i1> @uno3(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @uno3(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp uno <2 x float> %x, %y
; CHECK-NEXT: ret <2 x i1> [[CMP2]]
;
%cmp1 = fcmp uno <2 x float> %x, zeroinitializer
%cmp2 = fcmp uno <2 x float> %x, %y
%r = or <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define <2 x i1> @uno4(<2 x double> %x, <2 x double> %y) {
; CHECK-LABEL: @uno4(
; CHECK-NEXT: [[CMP2:%.*]] = fcmp uno <2 x double> %y, %x
; CHECK-NEXT: ret <2 x i1> [[CMP2]]
;
%cmp1 = fcmp uno <2 x double> %x, <double 42.0, double 42.0>
%cmp2 = fcmp uno <2 x double> %y, %x
%r = or <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define i1 @uno5(float %x, float %y) {
; CHECK-LABEL: @uno5(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno float %x, %y
; CHECK-NEXT: ret i1 [[CMP1]]
;
%cmp1 = fcmp uno float %x, %y
%cmp2 = fcmp uno float 0.0, %x
%r = or i1 %cmp1, %cmp2
ret i1 %r
}
define i1 @uno6(double %x, double %y) {
; CHECK-LABEL: @uno6(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno double %y, %x
; CHECK-NEXT: ret i1 [[CMP1]]
;
%cmp1 = fcmp uno double %y, %x
%cmp2 = fcmp uno double 42.0, %x
%r = or i1 %cmp1, %cmp2
ret i1 %r
}
define <2 x i1> @uno7(<2 x float> %x, <2 x float> %y) {
; CHECK-LABEL: @uno7(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno <2 x float> %x, %y
; CHECK-NEXT: ret <2 x i1> [[CMP1]]
;
%nnan = fdiv nnan <2 x float> %x, %y
%cmp1 = fcmp uno <2 x float> %x, %y
%cmp2 = fcmp uno <2 x float> %x, %nnan
%r = or <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}
define <2 x i1> @uno8(<2 x double> %x, <2 x double> %y) {
; CHECK-LABEL: @uno8(
; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno <2 x double> %y, %x
; CHECK-NEXT: ret <2 x i1> [[CMP1]]
;
%cmp1 = fcmp uno <2 x double> %y, %x
%cmp2 = fcmp uno <2 x double> %x, <double 0x7ff0000000000000, double 42.0>
%r = or <2 x i1> %cmp1, %cmp2
ret <2 x i1> %r
}