blob: a3d87439d74cfe93e5cd346623cd19a06a70f0d2 [file] [log] [blame]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instsimplify -march=nvptx64 --mcpu=sm_86 --mattr=+ptx72 -S | FileCheck %s
; Check constant-folding for NVVM add intrinsics with different rounding modes
;###############################################################
;# Add(1.25, -2.0) #
;###############################################################
; Tests addition of two normal numbers (1.25 and -2.0) where the result
; is exactly representable. All rounding modes produce the same result.
define double @test_1_25_minus_2_rm_d() {
; CHECK-LABEL: define double @test_1_25_minus_2_rm_d() {
; CHECK-NEXT: ret double -7.500000e-01
;
%res = call double @llvm.nvvm.add.rm.d(double 1.25, double -2.0)
ret double %res
}
define double @test_1_25_minus_2_rn_d() {
; CHECK-LABEL: define double @test_1_25_minus_2_rn_d() {
; CHECK-NEXT: ret double -7.500000e-01
;
%res = call double @llvm.nvvm.add.rn.d(double 1.25, double -2.0)
ret double %res
}
define double @test_1_25_minus_2_rp_d() {
; CHECK-LABEL: define double @test_1_25_minus_2_rp_d() {
; CHECK-NEXT: ret double -7.500000e-01
;
%res = call double @llvm.nvvm.add.rp.d(double 1.25, double -2.0)
ret double %res
}
define double @test_1_25_minus_2_rz_d() {
; CHECK-LABEL: define double @test_1_25_minus_2_rz_d() {
; CHECK-NEXT: ret double -7.500000e-01
;
%res = call double @llvm.nvvm.add.rz.d(double 1.25, double -2.0)
ret double %res
}
define float @test_1_25_minus_2_rm_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rm_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rm.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rn_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rn_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rn.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rp_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rp_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rp.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rz_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rz_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rz.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rm_ftz_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rm_ftz_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rn_ftz_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rn_ftz_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rp_ftz_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rp_ftz_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float 1.25, float -2.0)
ret float %res
}
define float @test_1_25_minus_2_rz_ftz_f() {
; CHECK-LABEL: define float @test_1_25_minus_2_rz_ftz_f() {
; CHECK-NEXT: ret float -7.500000e-01
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float 1.25, float -2.0)
ret float %res
}
;###############################################################
;# Add(0.0, NaN) #
;###############################################################
; Tests addition of a zero with NaN.
; The result is always NaN and the operation is not constant-folded.
define double @test_zero_plus_nan_rm_d() {
; CHECK-LABEL: define double @test_zero_plus_nan_rm_d() {
; CHECK-NEXT: [[RES:%.*]] = call double @llvm.nvvm.add.rm.d(double 0.000000e+00, double 0x7FF4444400000000)
; CHECK-NEXT: ret double [[RES]]
;
%res = call double @llvm.nvvm.add.rm.d(double 0.0, double 0x7ff4444400000000)
ret double %res
}
define double @test_zero_plus_nan_rn_d() {
; CHECK-LABEL: define double @test_zero_plus_nan_rn_d() {
; CHECK-NEXT: [[RES:%.*]] = call double @llvm.nvvm.add.rn.d(double 0.000000e+00, double 0x7FF4444400000000)
; CHECK-NEXT: ret double [[RES]]
;
%res = call double @llvm.nvvm.add.rn.d(double 0.0, double 0x7ff4444400000000)
ret double %res
}
define double @test_zero_plus_nan_rp_d() {
; CHECK-LABEL: define double @test_zero_plus_nan_rp_d() {
; CHECK-NEXT: [[RES:%.*]] = call double @llvm.nvvm.add.rp.d(double 0.000000e+00, double 0x7FF4444400000000)
; CHECK-NEXT: ret double [[RES]]
;
%res = call double @llvm.nvvm.add.rp.d(double 0.0, double 0x7ff4444400000000)
ret double %res
}
define double @test_zero_plus_nan_rz_d() {
; CHECK-LABEL: define double @test_zero_plus_nan_rz_d() {
; CHECK-NEXT: [[RES:%.*]] = call double @llvm.nvvm.add.rz.d(double 0.000000e+00, double 0x7FF4444400000000)
; CHECK-NEXT: ret double [[RES]]
;
%res = call double @llvm.nvvm.add.rz.d(double 0.0, double 0x7ff4444400000000)
ret double %res
}
define float @test_zero_plus_nan_rm_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rm_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rm.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rm.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rn_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rn_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rn.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rn.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rp_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rp_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rp.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rp.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rz_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rz_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rz.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rz.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rm_ftz_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rm_ftz_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rm.ftz.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rn_ftz_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rn_ftz_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rn.ftz.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rp_ftz_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rp_ftz_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rp.ftz.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
define float @test_zero_plus_nan_rz_ftz_f() {
; CHECK-LABEL: define float @test_zero_plus_nan_rz_ftz_f() {
; CHECK-NEXT: [[RES:%.*]] = call float @llvm.nvvm.add.rz.ftz.f(float 0.000000e+00, float 0x7FFF444400000000)
; CHECK-NEXT: ret float [[RES]]
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float 0.0, float 0x7FFF444400000000)
ret float %res
}
;###############################################################
;# Add(Subnormal, Subnormal) -> Normal #
;###############################################################
; Tests addition of two positive subnormal numbers (2^-127)
; - Without FTZ: The result is the sum of the subnormals (2^-126) - a normal number
; - With FTZ: The inputs are flushed to zero, so the result is zero (despite the output being normal)
define double @test_subnorm_plus_subnorm_to_normal_rm_d() {
; CHECK-LABEL: define double @test_subnorm_plus_subnorm_to_normal_rm_d() {
; CHECK-NEXT: ret double 0x3810000000000000
;
%res = call double @llvm.nvvm.add.rm.d(double 0x3800000000000000, double 0x3800000000000000)
ret double %res
}
define double @test_subnorm_plus_subnorm_to_normal_rn_d() {
; CHECK-LABEL: define double @test_subnorm_plus_subnorm_to_normal_rn_d() {
; CHECK-NEXT: ret double 0x3810000000000000
;
%res = call double @llvm.nvvm.add.rn.d(double 0x3800000000000000, double 0x3800000000000000)
ret double %res
}
define double @test_subnorm_plus_subnorm_to_normal_rp_d() {
; CHECK-LABEL: define double @test_subnorm_plus_subnorm_to_normal_rp_d() {
; CHECK-NEXT: ret double 0x3810000000000000
;
%res = call double @llvm.nvvm.add.rp.d(double 0x3800000000000000, double 0x3800000000000000)
ret double %res
}
define double @test_subnorm_plus_subnorm_to_normal_rz_d() {
; CHECK-LABEL: define double @test_subnorm_plus_subnorm_to_normal_rz_d() {
; CHECK-NEXT: ret double 0x3810000000000000
;
%res = call double @llvm.nvvm.add.rz.d(double 0x3800000000000000, double 0x3800000000000000)
ret double %res
}
define float @test_subnorm_plus_subnorm_to_normal_rm_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rm_f() {
; CHECK-NEXT: ret float 0x3810000000000000
;
%res = call float @llvm.nvvm.add.rm.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rn_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rn_f() {
; CHECK-NEXT: ret float 0x3810000000000000
;
%res = call float @llvm.nvvm.add.rn.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rp_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rp_f() {
; CHECK-NEXT: ret float 0x3810000000000000
;
%res = call float @llvm.nvvm.add.rp.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rz_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rz_f() {
; CHECK-NEXT: ret float 0x3810000000000000
;
%res = call float @llvm.nvvm.add.rz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rm_ftz_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rm_ftz_f() {
; CHECK-NEXT: ret float 0.000000e+00
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rn_ftz_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rn_ftz_f() {
; CHECK-NEXT: ret float 0.000000e+00
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rp_ftz_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rp_ftz_f() {
; CHECK-NEXT: ret float 0.000000e+00
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_subnorm_plus_subnorm_to_normal_rz_ftz_f() {
; CHECK-LABEL: define float @test_subnorm_plus_subnorm_to_normal_rz_ftz_f() {
; CHECK-NEXT: ret float 0.000000e+00
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
;###############################################################
;# Add(Normal, -Subnormal) -> Subnormal #
;###############################################################
; Tests addition of 2^-126 (the smallest normal number) and -(2^127).
; - Without FTZ: The result is correctly computed as a subnormal (2^127)
; - With FTZ: The result is flushed to zero.
; This verifies that the output is also flushed to zero, as we'd end up
; with 2^-126 if we only flushed the inputs.
define double @test_normal_minus_subnorm_to_subnorm_rm_d() {
; CHECK-LABEL: define double @test_normal_minus_subnorm_to_subnorm_rm_d() {
; CHECK-NEXT: ret double 0x3800000000000000
;
%res = call double @llvm.nvvm.add.rm.d(double 0x3810000000000000, double 0xB800000000000000)
ret double %res
}
define double @test_normal_minus_subnorm_to_subnorm_rn_d() {
; CHECK-LABEL: define double @test_normal_minus_subnorm_to_subnorm_rn_d() {
; CHECK-NEXT: ret double 0x3800000000000000
;
%res = call double @llvm.nvvm.add.rn.d(double 0x3810000000000000, double 0xB800000000000000)
ret double %res
}
define double @test_normal_minus_subnorm_to_subnorm_rp_d() {
; CHECK-LABEL: define double @test_normal_minus_subnorm_to_subnorm_rp_d() {
; CHECK-NEXT: ret double 0x3800000000000000
;
%res = call double @llvm.nvvm.add.rp.d(double 0x3810000000000000, double 0xB800000000000000)
ret double %res
}
define double @test_normal_minus_subnorm_to_subnorm_rz_d() {
; CHECK-LABEL: define double @test_normal_minus_subnorm_to_subnorm_rz_d() {
; CHECK-NEXT: ret double 0x3800000000000000
;
%res = call double @llvm.nvvm.add.rz.d(double 0x3810000000000000, double 0xB800000000000000)
ret double %res
}
define float @test_normal_minus_subnorm_to_subnorm_rm_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rm_f() {
; CHECK-NEXT: ret float 0x3800000000000000
;
%res = call float @llvm.nvvm.add.rm.f(float 0x3810000000000000, float 0xB800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rn_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rn_f() {
; CHECK-NEXT: ret float 0x3800000000000000
;
%res = call float @llvm.nvvm.add.rn.f(float 0x3810000000000000, float 0xB800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rp_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rp_f() {
; CHECK-NEXT: ret float 0x3800000000000000
;
%res = call float @llvm.nvvm.add.rp.f(float 0x3810000000000000, float 0xB800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rz_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rz_f() {
; CHECK-NEXT: ret float 0x3800000000000000
;
%res = call float @llvm.nvvm.add.rz.f(float 0x3810000000000000, float 0xB800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rm_ftz_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rm_ftz_f() {
; CHECK-NEXT: ret float 0x3810000000000000
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float 0x3810000000000000, float 0xB800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rn_ftz_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rn_ftz_f() {
; CHECK-NEXT: ret float 0x3810000000000000
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float 0x3810000000000000, float 0xB800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rp_ftz_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rp_ftz_f() {
; CHECK-NEXT: ret float 0.000000e+00
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
define float @test_normal_minus_subnorm_to_subnorm_rz_ftz_f() {
; CHECK-LABEL: define float @test_normal_minus_subnorm_to_subnorm_rz_ftz_f() {
; CHECK-NEXT: ret float 0.000000e+00
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float 0x3800000000000000, float 0x3800000000000000)
ret float %res
}
;###############################################################
;# Add(1.0, 2^(-25)) #
;###############################################################
; Tests addition of 1.0 and 2^(-25) where the exact result falls between
; 1.0 and 1.0 + 2^(-23):
; - RN, RZ, RM: Return 1.0 (rounding toward nearest/zero/down)
; - RP: Returns 1.0 + 2^(-23) (rounding up)
define float @test_1_plus_ulp_rm_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rm_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rm.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rn_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rn_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rp_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rp_f() {
; CHECK-NEXT: ret float 0x3FF0000020000000
;
%res = call float @llvm.nvvm.add.rp.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rz_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rz_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rz.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rm_ftz_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rm_ftz_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rn_ftz_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rn_ftz_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rp_ftz_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rp_ftz_f() {
; CHECK-NEXT: ret float 0x3FF0000020000000
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_1_plus_ulp_rz_ftz_f() {
; CHECK-LABEL: define float @test_1_plus_ulp_rz_ftz_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float 1.0, float 0x3E60000000000000)
ret float %res
}
;###############################################################
;# Add(1.0, 2^(-54)) #
;###############################################################
; Tests addition of 1.0 and 2^(-54) where the exact result falls between
; 1.0 and 1.0 + 2^(-52):
; - RN, RZ, RM: Return 1.0 (rounding to nearest/zero/down)
; - RP: Returns 1.0 + 2^(-52) (rounding up)
define double @test_1_plus_ulp_rm_d() {
; CHECK-LABEL: define double @test_1_plus_ulp_rm_d() {
; CHECK-NEXT: ret double 1.000000e+00
;
%res = call double @llvm.nvvm.add.rm.d(double 1.0, double 0x3C90000000000000)
ret double %res
}
define double @test_1_plus_ulp_rn_d() {
; CHECK-LABEL: define double @test_1_plus_ulp_rn_d() {
; CHECK-NEXT: ret double 1.000000e+00
;
%res = call double @llvm.nvvm.add.rn.d(double 1.0, double 0x3C90000000000000)
ret double %res
}
define double @test_1_plus_ulp_rp_d() {
; CHECK-LABEL: define double @test_1_plus_ulp_rp_d() {
; CHECK-NEXT: ret double 0x3FF0000000000001
;
%res = call double @llvm.nvvm.add.rp.d(double 1.0, double 0x3C90000000000000)
ret double %res
}
define double @test_1_plus_ulp_rz_d() {
; CHECK-LABEL: define double @test_1_plus_ulp_rz_d() {
; CHECK-NEXT: ret double 1.000000e+00
;
%res = call double @llvm.nvvm.add.rz.d(double 1.0, double 0x3C90000000000000)
ret double %res
}
;###############################################################
;# Add(-1.0, 2^(-25)) #
;###############################################################
; Tests addition of -1.0 and 2^(-25)) where the exact result falls between
; -1.0 and -1.0 + 2^(-23):
; - RN, RM: Returns -1.0 (rounding toward nearest/down)
; - RZ, RP: Return -1.0 + 2^(-23) (rounding toward zero/up)
define float @test_neg_1_plus_ulp_rm_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rm_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rm.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rn_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rn_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rp_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rp_f() {
; CHECK-NEXT: ret float 0xBFEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rp.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rz_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rz_f() {
; CHECK-NEXT: ret float 0xBFEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rz.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rm_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rm_ftz_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rn_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rn_ftz_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rp_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rp_ftz_f() {
; CHECK-NEXT: ret float 0xBFEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
define float @test_neg_1_plus_ulp_rz_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_plus_ulp_rz_ftz_f() {
; CHECK-NEXT: ret float 0xBFEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float -1.0, float 0x3E60000000000000)
ret float %res
}
;###############################################################
;# Add(-1.0, 2^(-54)) #
;###############################################################
; Tests addition of -1.0 and 2^(-54) where the exact result falls between
; -1.0 and -1.0 + 2^(-52):
; - RN, RM: Return -1.0 (rounding toward nearest/down)
; - RZ, RP: Return -1.0 + 2^(-52) (rounding toward zero/up)
define double @test_neg_1_plus_ulp_rm_d() {
; CHECK-LABEL: define double @test_neg_1_plus_ulp_rm_d() {
; CHECK-NEXT: ret double -1.000000e+00
;
%res = call double @llvm.nvvm.add.rm.d(double -1.0, double 0x3C90000000000000)
ret double %res
}
define double @test_neg_1_plus_ulp_rn_d() {
; CHECK-LABEL: define double @test_neg_1_plus_ulp_rn_d() {
; CHECK-NEXT: ret double -1.000000e+00
;
%res = call double @llvm.nvvm.add.rn.d(double -1.0, double 0x3C90000000000000)
ret double %res
}
define double @test_neg_1_plus_ulp_rp_d() {
; CHECK-LABEL: define double @test_neg_1_plus_ulp_rp_d() {
; CHECK-NEXT: ret double 0xBFEFFFFFFFFFFFFF
;
%res = call double @llvm.nvvm.add.rp.d(double -1.0, double 0x3C90000000000000)
ret double %res
}
define double @test_neg_1_plus_ulp_rz_d() {
; CHECK-LABEL: define double @test_neg_1_plus_ulp_rz_d() {
; CHECK-NEXT: ret double 0xBFEFFFFFFFFFFFFF
;
%res = call double @llvm.nvvm.add.rz.d(double -1.0, double 0x3C90000000000000)
ret double %res
}
;###############################################################
;# Add(1.0, -2^(-25)) #
;###############################################################
; Tests addition of 1.0 and -2^(-25) where the exact result falls between
; 1.0 and 1.0 - 2^(-23):
; - RN, RP: Return 1.0 (rounding toward nearest/up)
; - RZ, RM: Return 1.0 - 2^(-23) (rounding toward zero/down)
define float @test_1_minus_ulp_rm_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rm_f() {
; CHECK-NEXT: ret float 0x3FEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rm.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rn_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rn_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rp_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rp_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rp.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rz_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rz_f() {
; CHECK-NEXT: ret float 0x3FEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rz.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rm_ftz_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rm_ftz_f() {
; CHECK-NEXT: ret float 0x3FEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rn_ftz_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rn_ftz_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rp_ftz_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rp_ftz_f() {
; CHECK-NEXT: ret float 1.000000e+00
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_1_minus_ulp_rz_ftz_f() {
; CHECK-LABEL: define float @test_1_minus_ulp_rz_ftz_f() {
; CHECK-NEXT: ret float 0x3FEFFFFFE0000000
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float 1.0, float 0xBE60000000000000)
ret float %res
}
;###############################################################
;# Add(1.0, -2^(-54)) #
;###############################################################
; Tests addition of 1.0 and -2^(-54) where the exact result falls between
; 1.0 and 1.0 - 2^(-52):
; - RN, RP: Return 1.0 (rounding toward nearest/up)
; - RZ, RM: Return 1.0 - 2^(-52) (rounding toward zero/down)
define double @test_1_minus_ulp_rm_d() {
; CHECK-LABEL: define double @test_1_minus_ulp_rm_d() {
; CHECK-NEXT: ret double 0x3FEFFFFFFFFFFFFF
;
%res = call double @llvm.nvvm.add.rm.d(double 1.0, double 0xBC90000000000000)
ret double %res
}
define double @test_1_minus_ulp_rn_d() {
; CHECK-LABEL: define double @test_1_minus_ulp_rn_d() {
; CHECK-NEXT: ret double 1.000000e+00
;
%res = call double @llvm.nvvm.add.rn.d(double 1.0, double 0xBC90000000000000)
ret double %res
}
define double @test_1_minus_ulp_rp_d() {
; CHECK-LABEL: define double @test_1_minus_ulp_rp_d() {
; CHECK-NEXT: ret double 1.000000e+00
;
%res = call double @llvm.nvvm.add.rp.d(double 1.0, double 0xBC90000000000000)
ret double %res
}
define double @test_1_minus_ulp_rz_d() {
; CHECK-LABEL: define double @test_1_minus_ulp_rz_d() {
; CHECK-NEXT: ret double 0x3FEFFFFFFFFFFFFF
;
%res = call double @llvm.nvvm.add.rz.d(double 1.0, double 0xBC90000000000000)
ret double %res
}
;###############################################################
;# Add(-1.0, -2^(-25)) #
;###############################################################
; Tests addition of -1.0 and -2^(-25) where the exact result falls between
; -1.0 and -1.0 - 2^(-23):
; - RN, RZ, RP: Return -1.0 (rounding to nearest/zero/up)
; - RM: Return -1.0 - 2^(-23) (rounding down)
define float @test_neg_1_minus_ulp_rm_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rm_f() {
; CHECK-NEXT: ret float 0xBFF0000020000000
;
%res = call float @llvm.nvvm.add.rm.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rn_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rn_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rp_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rp_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rp.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rz_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rz_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rz.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rm_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rm_ftz_f() {
; CHECK-NEXT: ret float 0xBFF0000020000000
;
%res = call float @llvm.nvvm.add.rm.ftz.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rn_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rn_ftz_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rn.ftz.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rp_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rp_ftz_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rp.ftz.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
define float @test_neg_1_minus_ulp_rz_ftz_f() {
; CHECK-LABEL: define float @test_neg_1_minus_ulp_rz_ftz_f() {
; CHECK-NEXT: ret float -1.000000e+00
;
%res = call float @llvm.nvvm.add.rz.ftz.f(float -1.0, float 0xBE60000000000000)
ret float %res
}
;###############################################################
;# Add(-1.0, -2^(-54)) #
;###############################################################
; Tests addition of -1.0 and -2^(-54) where the exact result falls between
; -1.0 and -1.0 - 2^(-52):
; - RN, RZ, RP: Return -1.0 (rounding to nearest/zero/up)
; - RM: Return -1.0 - 2^(-52) (rounding down)
define double @test_neg_1_minus_ulp_rm_d() {
; CHECK-LABEL: define double @test_neg_1_minus_ulp_rm_d() {
; CHECK-NEXT: ret double 0xBFF0000000000001
;
%res = call double @llvm.nvvm.add.rm.d(double -1.0, double 0xBC90000000000000)
ret double %res
}
define double @test_neg_1_minus_ulp_rn_d() {
; CHECK-LABEL: define double @test_neg_1_minus_ulp_rn_d() {
; CHECK-NEXT: ret double -1.000000e+00
;
%res = call double @llvm.nvvm.add.rn.d(double -1.0, double 0xBC90000000000000)
ret double %res
}
define double @test_neg_1_minus_ulp_rp_d() {
; CHECK-LABEL: define double @test_neg_1_minus_ulp_rp_d() {
; CHECK-NEXT: ret double -1.000000e+00
;
%res = call double @llvm.nvvm.add.rp.d(double -1.0, double 0xBC90000000000000)
ret double %res
}
define double @test_neg_1_minus_ulp_rz_d() {
; CHECK-LABEL: define double @test_neg_1_minus_ulp_rz_d() {
; CHECK-NEXT: ret double -1.000000e+00
;
%res = call double @llvm.nvvm.add.rz.d(double -1.0, double 0xBC90000000000000)
ret double %res
}