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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=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 - make quiet and preserve the payload and signbit
define float @fsub_nan_op1(float %x) {
; CHECK-LABEL: @fsub_nan_op1(
; CHECK-NEXT: ret float 0x7FF9000000000000
;
%r = fsub float %x, 0x7FF1000000000000
ret float %r
}
define <2 x float> @fsub_nan_op1_vec(<2 x float> %x) {
; CHECK-LABEL: @fsub_nan_op1_vec(
; CHECK-NEXT: ret <2 x float> <float 0x7FF9000000000000, float 0xFFF9000000000000>
;
%r = fsub <2 x float> %x, <float 0x7FF1000000000000, float 0xFFF1000000000000>
ret <2 x float> %r
}
define <vscale x 1 x float> @fsub_nan_op1_scalable_vec_0(<vscale x 1 x float> %x) {
; CHECK-LABEL: @fsub_nan_op1_scalable_vec_0(
; CHECK-NEXT: ret <vscale x 1 x float> shufflevector (<vscale x 1 x float> insertelement (<vscale x 1 x float> poison, float 0x7FF9000000000000, i64 0), <vscale x 1 x float> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fsub <vscale x 1 x float> %x, splat (float 0x7FF1000000000000)
ret <vscale x 1 x float> %r
}
define <vscale x 1 x float> @fsub_nan_op1_scalable_vec_1(<vscale x 1 x float> %x) {
; CHECK-LABEL: @fsub_nan_op1_scalable_vec_1(
; CHECK-NEXT: ret <vscale x 1 x float> shufflevector (<vscale x 1 x float> insertelement (<vscale x 1 x float> poison, float 0xFFF9000000000000, i64 0), <vscale x 1 x float> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fsub <vscale x 1 x float> %x, splat (float 0xFFF1000000000000)
ret <vscale x 1 x float> %r
}
; Signaling and signed - make quiet and preserve the payload and signbit
define double @fmul_nan_op0(double %x) {
; CHECK-LABEL: @fmul_nan_op0(
; CHECK-NEXT: ret double 0xFFF8000000000001
;
%r = fmul double 0xFFF0000000000001, %x
ret double %r
}
define <2 x double> @fmul_nan_op0_vec(<2 x double> %x) {
; CHECK-LABEL: @fmul_nan_op0_vec(
; CHECK-NEXT: ret <2 x double> <double 0xFFF8000000000001, double 0xFFF8DEADDEADDEAD>
;
%r = fmul <2 x double> <double 0xFFF0000000000001, double 0xFFF0DEADDEADDEAD>, %x
ret <2 x double> %r
}
define <vscale x 1 x double> @fmul_nan_op0_scalable_vec_0(<vscale x 1 x double> %x) {
; CHECK-LABEL: @fmul_nan_op0_scalable_vec_0(
; CHECK-NEXT: ret <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0xFFF8000000000001, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fmul <vscale x 1 x double> splat (double 0xFFF0000000000001), %x
ret <vscale x 1 x double> %r
}
define <vscale x 1 x double> @fmul_nan_op0_scalable_vec_1(<vscale x 1 x double> %x) {
; CHECK-LABEL: @fmul_nan_op0_scalable_vec_1(
; CHECK-NEXT: ret <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0xFFF8DEADDEADDEAD, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fmul <vscale x 1 x double> splat (double 0xFFF0DEADDEADDEAD), %x
ret <vscale x 1 x 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
}
define <vscale x 1 x double> @fmul_nan_op1_scalable_vec(<vscale x 1 x double> %x) {
; CHECK-LABEL: @fmul_nan_op1_scalable_vec(
; CHECK-NEXT: ret <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0x7FF8000000000000, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fmul <vscale x 1 x double> %x, splat (double 0x7FF8000000000000)
ret <vscale x 1 x double> %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
}
define <vscale x 1 x double> @fdivl_nan_op0_scalable_vec(<vscale x 1 x double> %x) {
; CHECK-LABEL: @fdivl_nan_op0_scalable_vec(
; CHECK-NEXT: ret <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0xFFF800000000000F, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fdiv <vscale x 1 x double> splat (double 0xFFF800000000000F), %x
ret <vscale x 1 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
}
define <vscale x 1 x half> @fdiv_nan_op1_scalable_vec(<vscale x 1 x half> %x) {
; CHECK-LABEL: @fdiv_nan_op1_scalable_vec(
; CHECK-NEXT: ret <vscale x 1 x half> shufflevector (<vscale x 1 x half> insertelement (<vscale x 1 x half> poison, half 0xH7FFF, i64 0), <vscale x 1 x half> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fdiv <vscale x 1 x half> %x, splat (half 0xH7FFF)
ret <vscale x 1 x half> %r
}
; Vector with poison element
define <2 x double> @fsub_nan_poison_op1(<2 x double> %x) {
; CHECK-LABEL: @fsub_nan_poison_op1(
; CHECK-NEXT: ret <2 x double> <double 0xFFFF00000000DEAD, double poison>
;
%r = fsub <2 x double> %x, <double 0xFFFF00000000DEAD, double poison>
ret <2 x double> %r
}
; Vector with poison element
define <2 x double> @frem_nan_poison_op0(<2 x double> %x) {
; CHECK-LABEL: @frem_nan_poison_op0(
; CHECK-NEXT: ret <2 x double> <double 0xFFFF00000000DEAD, double poison>
;
%r = frem <2 x double> <double 0xFFFF00000000DEAD, double poison>, %x
ret <2 x double> %r
}
; Vector with poison and undef elements
define <3 x double> @fadd_nan_poison_undef_op1(<3 x double> %x) {
; CHECK-LABEL: @fadd_nan_poison_undef_op1(
; CHECK-NEXT: [[R:%.*]] = fadd <3 x double> [[X:%.*]], <double 0xFFFF00000000DEAD, double poison, double undef>
; CHECK-NEXT: ret <3 x double> [[R]]
;
%r = fadd <3 x double> %x, <double 0xFFFF00000000DEAD, double poison, double undef>
ret <3 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 0x7FFABCDEF0123456
;
%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 0xFFF9234567890ABC, double 0x7FF8000000000001>
;
%r = fsub <2 x double> <double -0.0, double -0.0>, <double 0xFFF1234567890ABC, double 0x7FF0000000000001>
ret <2 x double> %r
}
define <vscale x 1 x double> @fneg_nan_2_scalable_vec() {
; CHECK-LABEL: @fneg_nan_2_scalable_vec(
; CHECK-NEXT: ret <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0xFFF9234567890ABC, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
;
%r = fsub <vscale x 1 x double> splat (double -0.0), splat (double 0xFFF1234567890ABC)
ret <vscale x 1 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
}
; FIXME: This doesn't behave the same way as the fixed-length vectors above
define <vscale x 1 x double> @unary_fneg_nan_2_scalable_vec_0() {
; CHECK-LABEL: @unary_fneg_nan_2_scalable_vec_0(
; CHECK-NEXT: [[R:%.*]] = fneg <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0xFFF1234567890ABC, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
; CHECK-NEXT: ret <vscale x 1 x double> [[R]]
;
%r = fneg <vscale x 1 x double> splat (double 0xFFF1234567890ABC)
ret <vscale x 1 x double> %r
}
; FIXME: This doesn't behave the same way as the fixed-length vectors above
define <vscale x 1 x double> @unary_fneg_nan_2_scalable_vec_1() {
; CHECK-LABEL: @unary_fneg_nan_2_scalable_vec_1(
; CHECK-NEXT: [[R:%.*]] = fneg <vscale x 1 x double> shufflevector (<vscale x 1 x double> insertelement (<vscale x 1 x double> poison, double 0x7FF0000000000001, i64 0), <vscale x 1 x double> poison, <vscale x 1 x i32> zeroinitializer)
; CHECK-NEXT: ret <vscale x 1 x double> [[R]]
;
%r = fneg <vscale x 1 x double> splat (double 0x7FF0000000000001)
ret <vscale x 1 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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%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 poison
;
%r = frem fast float %x, 0x7FF8000000000000
ret float %r
}
|