[llvm-branch-commits] [llvm] bdb748a - [ConstantFold] Add tests for fptoi.sat (NFC)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jan 10 08:41:00 PST 2021


Author: Nikita Popov
Date: 2021-01-10T17:08:11+01:00
New Revision: bdb748a0ab24b9d87f98d3cdbecdbbf504aed930

URL: https://github.com/llvm/llvm-project/commit/bdb748a0ab24b9d87f98d3cdbecdbbf504aed930
DIFF: https://github.com/llvm/llvm-project/commit/bdb748a0ab24b9d87f98d3cdbecdbbf504aed930.diff

LOG: [ConstantFold] Add tests for fptoi.sat (NFC)

Added: 
    llvm/test/Transforms/InstSimplify/fptoi-sat.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/fptoi-sat.ll b/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
new file mode 100644
index 000000000000..c418abd76019
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/fptoi-sat.ll
@@ -0,0 +1,684 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -instsimplify < %s | FileCheck %s
+
+declare i32 @llvm.fptosi.sat.i32.f64(double)
+declare i32 @llvm.fptoui.sat.i32.f64(double)
+declare i32 @llvm.fptosi.sat.i32.f32(float)
+declare i32 @llvm.fptoui.sat.i32.f32(float)
+
+declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double>)
+declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double>)
+declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float>)
+declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float>)
+
+;
+;
+; F64 -> I32
+;
+;
+
+define i32 @fptosi_f64_to_i32_poison() {
+; CHECK-LABEL: @fptosi_f64_to_i32_poison(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double poison)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double poison)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_undef() {
+; CHECK-LABEL: @fptosi_f64_to_i32_undef(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double undef)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double undef)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_pos_zero() {
+; CHECK-LABEL: @fptosi_f64_to_i32_pos_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_neg_zero() {
+; CHECK-LABEL: @fptosi_f64_to_i32_neg_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double -0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -0.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_exact() {
+; CHECK-LABEL: @fptosi_f64_to_i32_exact(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 4.200000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 42.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_trunc() {
+; CHECK-LABEL: @fptosi_f64_to_i32_trunc(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 4.290000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 42.9)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_trunc_neg() {
+; CHECK-LABEL: @fptosi_f64_to_i32_trunc_neg(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double -4.290000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -42.9)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_max_minus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_max_minus_1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0x41DFFFFFFF800000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 2147483646.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_max() {
+; CHECK-LABEL: @fptosi_f64_to_i32_max(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0x41DFFFFFFFC00000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 2147483647.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_max_plus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_max_plus_1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0x41E0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 2147483648.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_min_plus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_min_plus_1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0xC1DFFFFFFFC00000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -2147483647.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_min() {
+; CHECK-LABEL: @fptosi_f64_to_i32_min(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0xC1E0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -2147483648.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_min_minus_1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_min_minus_1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0xC1E0000000200000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double -2147483649.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_inf() {
+; CHECK-LABEL: @fptosi_f64_to_i32_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0x7FF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0x7ff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_neg_inf() {
+; CHECK-LABEL: @fptosi_f64_to_i32_neg_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0xFFF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0xfff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_nan1() {
+; CHECK-LABEL: @fptosi_f64_to_i32_nan1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0x7FF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0x7ff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_nan2() {
+; CHECK-LABEL: @fptosi_f64_to_i32_nan2(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0x7FF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0x7ff4000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_nan3() {
+; CHECK-LABEL: @fptosi_f64_to_i32_nan3(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0xFFF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0xfff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f64_to_i32_nan4() {
+; CHECK-LABEL: @fptosi_f64_to_i32_nan4(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f64(double 0xFFF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f64(double 0xfff4000000000000)
+  ret i32 %r
+}
+
+define <2 x i32> @fptosi_f64_to_i32_vec() {
+; CHECK-LABEL: @fptosi_f64_to_i32_vec(
+; CHECK-NEXT:    [[R:%.*]] = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double> <double 4.290000e+01, double -4.290000e+01>)
+; CHECK-NEXT:    ret <2 x i32> [[R]]
+;
+  %r = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double> <double 42.9, double -42.9>)
+  ret <2 x i32> %r
+}
+
+;
+;
+; F64 -> U32
+;
+;
+
+define i32 @fptoui_f64_to_i32_poison() {
+; CHECK-LABEL: @fptoui_f64_to_i32_poison(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double poison)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double poison)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_undef() {
+; CHECK-LABEL: @fptoui_f64_to_i32_undef(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double undef)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double undef)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_pos_zero() {
+; CHECK-LABEL: @fptoui_f64_to_i32_pos_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_neg_zero() {
+; CHECK-LABEL: @fptoui_f64_to_i32_neg_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double -0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double -0.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_exact() {
+; CHECK-LABEL: @fptoui_f64_to_i32_exact(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 4.200000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 42.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_trunc() {
+; CHECK-LABEL: @fptoui_f64_to_i32_trunc(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 4.290000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 42.9)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_trunc_neg() {
+; CHECK-LABEL: @fptoui_f64_to_i32_trunc_neg(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double -4.290000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double -42.9)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_max_minus_1() {
+; CHECK-LABEL: @fptoui_f64_to_i32_max_minus_1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0x41EFFFFFFFC00000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 4294967294.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_max() {
+; CHECK-LABEL: @fptoui_f64_to_i32_max(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0x41EFFFFFFFE00000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 4294967295.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_max_plus_1() {
+; CHECK-LABEL: @fptoui_f64_to_i32_max_plus_1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0x41F0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 4294967296.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_inf() {
+; CHECK-LABEL: @fptoui_f64_to_i32_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0x7FF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0x7ff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_neg_inf() {
+; CHECK-LABEL: @fptoui_f64_to_i32_neg_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0xFFF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0xfff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_nan1() {
+; CHECK-LABEL: @fptoui_f64_to_i32_nan1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0x7FF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0x7ff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_nan2() {
+; CHECK-LABEL: @fptoui_f64_to_i32_nan2(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0x7FF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0x7ff4000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_nan3() {
+; CHECK-LABEL: @fptoui_f64_to_i32_nan3(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0xFFF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0xfff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f64_to_i32_nan4() {
+; CHECK-LABEL: @fptoui_f64_to_i32_nan4(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f64(double 0xFFF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f64(double 0xfff4000000000000)
+  ret i32 %r
+}
+
+define <2 x i32> @fptoui_f64_to_i32_vec() {
+; CHECK-LABEL: @fptoui_f64_to_i32_vec(
+; CHECK-NEXT:    [[R:%.*]] = call <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double> <double 4.290000e+01, double -4.290000e+01>)
+; CHECK-NEXT:    ret <2 x i32> [[R]]
+;
+  %r = call <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double> <double 42.9, double -42.9>)
+  ret <2 x i32> %r
+}
+
+;
+;
+; F32 -> I32
+;
+;
+
+define i32 @fptosi_f32_to_i32_poison() {
+; CHECK-LABEL: @fptosi_f32_to_i32_poison(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float poison)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float poison)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_undef() {
+; CHECK-LABEL: @fptosi_f32_to_i32_undef(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float undef)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float undef)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_pos_zero() {
+; CHECK-LABEL: @fptosi_f32_to_i32_pos_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_neg_zero() {
+; CHECK-LABEL: @fptosi_f32_to_i32_neg_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float -0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float -0.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_exact() {
+; CHECK-LABEL: @fptosi_f32_to_i32_exact(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 4.200000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 42.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_trunc() {
+; CHECK-LABEL: @fptosi_f32_to_i32_trunc(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 4.250000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 42.5)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_trunc_neg() {
+; CHECK-LABEL: @fptosi_f32_to_i32_trunc_neg(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float -4.250000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float -42.5)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_below_max() {
+; CHECK-LABEL: @fptosi_f32_to_i32_below_max(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0x41DFFFFFE0000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 2147483520.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_above_max() {
+; CHECK-LABEL: @fptosi_f32_to_i32_above_max(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0x41E0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 2147483648.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_above_min() {
+; CHECK-LABEL: @fptosi_f32_to_i32_above_min(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0xC1DFFFFFE0000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float -2147483520.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_min() {
+; CHECK-LABEL: @fptosi_f32_to_i32_min(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0xC1E0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float -2147483648.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_below_min() {
+; CHECK-LABEL: @fptosi_f32_to_i32_below_min(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0xC1E0000020000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float -2147483904.0)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_inf() {
+; CHECK-LABEL: @fptosi_f32_to_i32_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0x7FF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0x7ff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_neg_inf() {
+; CHECK-LABEL: @fptosi_f32_to_i32_neg_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0xFFF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0xfff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_nan1() {
+; CHECK-LABEL: @fptosi_f32_to_i32_nan1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0x7FF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0x7ff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_nan2() {
+; CHECK-LABEL: @fptosi_f32_to_i32_nan2(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0x7FF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0x7ff4000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_nan3() {
+; CHECK-LABEL: @fptosi_f32_to_i32_nan3(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0xFFF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0xfff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptosi_f32_to_i32_nan4() {
+; CHECK-LABEL: @fptosi_f32_to_i32_nan4(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptosi.sat.i32.f32(float 0xFFF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptosi.sat.i32.f32(float 0xfff4000000000000)
+  ret i32 %r
+}
+
+define <2 x i32> @fptosi_f32_to_i32_vec() {
+; CHECK-LABEL: @fptosi_f32_to_i32_vec(
+; CHECK-NEXT:    [[R:%.*]] = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float> <float 4.250000e+01, float -4.250000e+01>)
+; CHECK-NEXT:    ret <2 x i32> [[R]]
+;
+  %r = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float> <float 42.5, float -42.5>)
+  ret <2 x i32> %r
+}
+
+;
+;
+; F32 -> U32
+;
+;
+
+define i32 @fptoui_f32_to_i32_poison() {
+; CHECK-LABEL: @fptoui_f32_to_i32_poison(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float poison)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float poison)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_undef() {
+; CHECK-LABEL: @fptoui_f32_to_i32_undef(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float undef)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float undef)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_pos_zero() {
+; CHECK-LABEL: @fptoui_f32_to_i32_pos_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_neg_zero() {
+; CHECK-LABEL: @fptoui_f32_to_i32_neg_zero(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float -0.000000e+00)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float -0.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_exact() {
+; CHECK-LABEL: @fptoui_f32_to_i32_exact(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 4.200000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 42.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_trunc() {
+; CHECK-LABEL: @fptoui_f32_to_i32_trunc(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 4.250000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 42.5)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_trunc_neg() {
+; CHECK-LABEL: @fptoui_f32_to_i32_trunc_neg(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float -4.250000e+01)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float -42.5)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_below_max() {
+; CHECK-LABEL: @fptoui_f32_to_i32_below_max(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0x41EFFFFFE0000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 4294967040.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_above_max() {
+; CHECK-LABEL: @fptoui_f32_to_i32_above_max(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0x41F0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 4294967296.0)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_inf() {
+; CHECK-LABEL: @fptoui_f32_to_i32_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0x7FF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0x7ff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_neg_inf() {
+; CHECK-LABEL: @fptoui_f32_to_i32_neg_inf(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0xFFF0000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0xfff0000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_nan1() {
+; CHECK-LABEL: @fptoui_f32_to_i32_nan1(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0x7FF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0x7ff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_nan2() {
+; CHECK-LABEL: @fptoui_f32_to_i32_nan2(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0x7FF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0x7ff4000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_nan3() {
+; CHECK-LABEL: @fptoui_f32_to_i32_nan3(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0xFFF8000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0xfff8000000000000)
+  ret i32 %r
+}
+
+define i32 @fptoui_f32_to_i32_nan4() {
+; CHECK-LABEL: @fptoui_f32_to_i32_nan4(
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.fptoui.sat.i32.f32(float 0xFFF4000000000000)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @llvm.fptoui.sat.i32.f32(float 0xfff4000000000000)
+  ret i32 %r
+}
+
+define <2 x i32> @fptoui_f32_to_i32_vec() {
+; CHECK-LABEL: @fptoui_f32_to_i32_vec(
+; CHECK-NEXT:    [[R:%.*]] = call <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float> <float 4.250000e+01, float -4.250000e+01>)
+; CHECK-NEXT:    ret <2 x i32> [[R]]
+;
+  %r = call <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float> <float 42.5, float -42.5>)
+  ret <2 x i32> %r
+}


        


More information about the llvm-branch-commits mailing list