fp-nan.ll
5.39 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
; Default NaN constant
define double @fadd_nan_op0(double %x) {
; CHECK-LABEL: @fadd_nan_op0(
; CHECK-NEXT: ret double 0x7FF8000000000000
;
%r = fadd double 0x7FF8000000000000, %x
ret double %r
}
; Sign bit is set
define double @fadd_nan_op1(double %x) {
; CHECK-LABEL: @fadd_nan_op1(
; CHECK-NEXT: ret double 0xFFF8000000000000
;
%r = fadd double %x, 0xFFF8000000000000
ret double %r
}
; Non-zero payload
define float @fsub_nan_op0(float %x) {
; CHECK-LABEL: @fsub_nan_op0(
; CHECK-NEXT: ret float 0x7FFFFF0000000000
;
%r = fsub float 0x7FFFFF0000000000, %x
ret float %r
}
; Signaling
define float @fsub_nan_op1(float %x) {
; CHECK-LABEL: @fsub_nan_op1(
; CHECK-NEXT: ret float 0x7FF1000000000000
;
%r = fsub float %x, 0x7FF1000000000000
ret float %r
}
; Signaling and signed
define double @fmul_nan_op0(double %x) {
; CHECK-LABEL: @fmul_nan_op0(
; CHECK-NEXT: ret double 0xFFF0000000000001
;
%r = fmul double 0xFFF0000000000001, %x
ret double %r
}
; Vector type
define <2 x float> @fmul_nan_op1(<2 x float> %x) {
; CHECK-LABEL: @fmul_nan_op1(
; CHECK-NEXT: ret <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>
;
%r = fmul <2 x float> %x, <float 0x7FF8000000000000, float 0x7FF8000000000000>
ret <2 x float> %r
}
; Vector signed and non-zero payload
define <2 x double> @fdiv_nan_op0(<2 x double> %x) {
; CHECK-LABEL: @fdiv_nan_op0(
; CHECK-NEXT: ret <2 x double> <double 0xFFF800000000000F, double 0xFFF800000000000F>
;
%r = fdiv <2 x double> <double 0xFFF800000000000F, double 0xFFF800000000000F>, %x
ret <2 x double> %r
}
; Vector with different NaN constant elements
define <2 x half> @fdiv_nan_op1(<2 x half> %x) {
; CHECK-LABEL: @fdiv_nan_op1(
; CHECK-NEXT: ret <2 x half> <half 0xH7FFF, half 0xHFF00>
;
%r = fdiv <2 x half> %x, <half 0xH7FFF, half 0xHFF00>
ret <2 x half> %r
}
; Vector with undef element
define <2 x double> @frem_nan_op0(<2 x double> %x) {
; CHECK-LABEL: @frem_nan_op0(
; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
;
%r = frem <2 x double> <double 0xFFFF000000000000, double undef>, %x
ret <2 x double> %r
}
define float @frem_nan_op1(float %x) {
; CHECK-LABEL: @frem_nan_op1(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = frem float %x, 0x7FF8000000000000
ret float %r
}
; Special-case: fneg must only change the sign bit (this is handled by constant folding).
define double @fneg_nan_1(double %x) {
; CHECK-LABEL: @fneg_nan_1(
; CHECK-NEXT: ret double 0xFFFABCDEF0123456
;
%r = fsub double -0.0, 0x7FFABCDEF0123456
ret double %r
}
define double @unary_fneg_nan_1(double %x) {
; CHECK-LABEL: @unary_fneg_nan_1(
; CHECK-NEXT: ret double 0xFFFABCDEF0123456
;
%r = fneg double 0x7FFABCDEF0123456
ret double %r
}
define <2 x double> @fneg_nan_2(<2 x double> %x) {
; CHECK-LABEL: @fneg_nan_2(
; CHECK-NEXT: ret <2 x double> <double 0x7FF1234567890ABC, double 0xFFF0000000000001>
;
%r = fsub <2 x double> <double -0.0, double -0.0>, <double 0xFFF1234567890ABC, double 0x7FF0000000000001>
ret <2 x double> %r
}
define <2 x double> @unary_fneg_nan_2(<2 x double> %x) {
; CHECK-LABEL: @unary_fneg_nan_2(
; CHECK-NEXT: ret <2 x double> <double 0x7FF1234567890ABC, double 0xFFF0000000000001>
;
%r = fneg <2 x double> <double 0xFFF1234567890ABC, double 0x7FF0000000000001>
ret <2 x double> %r
}
; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
define float @fadd_nan_op0_nnan(float %x) {
; CHECK-LABEL: @fadd_nan_op0_nnan(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fadd nnan float 0x7FF8000000000000, %x
ret float %r
}
define float @fadd_nan_op1_fast(float %x) {
; CHECK-LABEL: @fadd_nan_op1_fast(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fadd fast float %x, 0x7FF8000000000000
ret float %r
}
define float @fsub_nan_op0_fast(float %x) {
; CHECK-LABEL: @fsub_nan_op0_fast(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fsub fast float 0x7FF8000000000000, %x
ret float %r
}
define float @fsub_nan_op1_nnan(float %x) {
; CHECK-LABEL: @fsub_nan_op1_nnan(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fsub nnan float %x, 0x7FF8000000000000
ret float %r
}
define float @fmul_nan_op0_nnan(float %x) {
; CHECK-LABEL: @fmul_nan_op0_nnan(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fmul nnan float 0x7FF8000000000000, %x
ret float %r
}
define float @fmul_nan_op1_fast(float %x) {
; CHECK-LABEL: @fmul_nan_op1_fast(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fmul fast float %x, 0x7FF8000000000000
ret float %r
}
define float @fdiv_nan_op0_fast(float %x) {
; CHECK-LABEL: @fdiv_nan_op0_fast(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fdiv fast float 0x7FF8000000000000, %x
ret float %r
}
define float @fdiv_nan_op1_nnan(float %x) {
; CHECK-LABEL: @fdiv_nan_op1_nnan(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = fdiv nnan float %x, 0x7FF8000000000000
ret float %r
}
define float @frem_nan_op0_nnan(float %x) {
; CHECK-LABEL: @frem_nan_op0_nnan(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = frem nnan float 0x7FF8000000000000, %x
ret float %r
}
define float @frem_nan_op1_fast(float %x) {
; CHECK-LABEL: @frem_nan_op1_fast(
; CHECK-NEXT: ret float 0x7FF8000000000000
;
%r = frem fast float %x, 0x7FF8000000000000
ret float %r
}