Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/InstSimplify/fp-nan.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

337 lines
9.6 KiB
LLVM

; 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 +qnan
;
%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 -qnan
;
%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 +nan(0x3FF800)
;
%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 +nan(0x80000)
;
%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 +nan(0x80000), float -nan(0x80000)>
;
%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> splat (float +nan(0x80000))
;
%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> splat (float -nan(0x80000))
;
%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 -nan(0x1)
;
%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 -nan(0x1), double -nan(0xDEADDEADDEAD)>
;
%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> splat (double -nan(0x1))
;
%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> splat (double -nan(0xDEADDEADDEAD))
;
%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> splat (float +qnan)
;
%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> splat (double +qnan)
;
%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> splat (double -nan(0xF))
;
%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> splat (double -nan(0xF))
;
%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 +nan(0x1FF), half -nan(0x100)>
;
%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> splat (half +nan(0x1FF))
;
%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 -nan(0x700000000DEAD), 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 -nan(0x700000000DEAD), 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 -nan(0x700000000DEAD), 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 +qnan
;
%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 +nan(0x2BCDEF0123456)
;
%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 -nan(0x2BCDEF0123456)
;
%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 -nan(0x1234567890ABC), double +nan(0x1)>
;
%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> splat (double -nan(0x1234567890ABC))
;
%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 +snan(0x1234567890ABC), double -snan(0x1)>
;
%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: ret <vscale x 1 x double> splat (double +snan(0x1234567890ABC))
;
%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: ret <vscale x 1 x double> splat (double -snan(0x1))
;
%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
}