[llvm] cb29ba9 - [InstCombine] adjust tests for fptoui + trunc; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 11:25:02 PST 2023
Author: Sanjay Patel
Date: 2023-01-20T14:24:56-05:00
New Revision: cb29ba9c0f8726d768caff29f7c400c19774cbd8
URL: https://github.com/llvm/llvm-project/commit/cb29ba9c0f8726d768caff29f7c400c19774cbd8
DIFF: https://github.com/llvm/llvm-project/commit/cb29ba9c0f8726d768caff29f7c400c19774cbd8.diff
LOG: [InstCombine] adjust tests for fptoui + trunc; NFC
Tests were duplicated for undef-ness, but that's not necessary.
There were no tests for bfloat/double.
I deleted the fptosi tests for now because those will just
be a bitwidth adjustment to the fptoui tests once we settle
on the right set of tests.
I think it should just be 2 tests on either side of the
bitwidth boundary to allow a fold with a couple of extra
tests thrown in to show other type constraints are not
a factor.
Goes with:
D142093
Added:
Modified:
llvm/test/Transforms/InstCombine/trunc-fp-to-int.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/trunc-fp-to-int.ll b/llvm/test/Transforms/InstCombine/trunc-fp-to-int.ll
index e8d16e9d6353..add519417a32 100644
--- a/llvm/test/Transforms/InstCombine/trunc-fp-to-int.ll
+++ b/llvm/test/Transforms/InstCombine/trunc-fp-to-int.ll
@@ -1,407 +1,141 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=instcombine -S -o - %s | FileCheck %s
-; Negative test.
-define i15 @half_fptoui_i32_i15(half %x) {
-; CHECK-LABEL: @half_fptoui_i32_i15(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i15
-; CHECK-NEXT: ret i15 [[CONV_1]]
-;
- %conv = fptoui half %x to i32
- %conv.1 = trunc i32 %conv to i15
- ret i15 %conv.1
-}
-
-; Negative test.
-define i15 @half_fptoui_i32_i15_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptoui_i32_i15_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i15
-; CHECK-NEXT: ret i15 [[CONV_1]]
-;
- %conv = fptoui half %x to i32
- %conv.1 = trunc i32 %conv to i15
- ret i15 %conv.1
-}
+; Tests if an integer type can cover the entire range of an input
+; FP value. If so, we can remove an intermediate cast to a smaller
+; int type (remove a truncate).
define i16 @half_fptoui_i17_i16(half %x) {
; CHECK-LABEL: @half_fptoui_i17_i16(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i17
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i17 [[CONV]] to i16
-; CHECK-NEXT: ret i16 [[CONV_1]]
+; CHECK-NEXT: [[I:%.*]] = fptoui half [[X:%.*]] to i17
+; CHECK-NEXT: [[R:%.*]] = trunc i17 [[I]] to i16
+; CHECK-NEXT: ret i16 [[R]]
;
- %conv = fptoui half %x to i17
- %conv.1 = trunc i17 %conv to i16
- ret i16 %conv.1
+ %i = fptoui half %x to i17
+ %r = trunc i17 %i to i16
+ ret i16 %r
}
-define i16 @half_fptoui_i17_i16_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptoui_i17_i16_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i17
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i17 [[CONV]] to i16
-; CHECK-NEXT: ret i16 [[CONV_1]]
+; Negative test - not enough bits to hold max half value (65504).
+
+define i15 @half_fptoui_i17_i15(half %x) {
+; CHECK-LABEL: @half_fptoui_i17_i15(
+; CHECK-NEXT: [[I:%.*]] = fptoui half [[X:%.*]] to i17
+; CHECK-NEXT: [[R:%.*]] = trunc i17 [[I]] to i15
+; CHECK-NEXT: ret i15 [[R]]
;
- %conv = fptoui half %x to i17
- %conv.1 = trunc i17 %conv to i16
- ret i16 %conv.1
+ %i = fptoui half %x to i17
+ %r = trunc i17 %i to i15
+ ret i15 %r
}
+; Wider intermediate type is ok.
+
define i16 @half_fptoui_i32_i16(half %x) {
; CHECK-LABEL: @half_fptoui_i32_i16(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i16
-; CHECK-NEXT: ret i16 [[CONV_1]]
+; CHECK-NEXT: [[I:%.*]] = fptoui half [[X:%.*]] to i32
+; CHECK-NEXT: [[R:%.*]] = trunc i32 [[I]] to i16
+; CHECK-NEXT: ret i16 [[R]]
;
- %conv = fptoui half %x to i32
- %conv.1 = trunc i32 %conv to i16
- ret i16 %conv.1
+ %i = fptoui half %x to i32
+ %r = trunc i32 %i to i16
+ ret i16 %r
}
-define i16 @half_fptoui_i32_i16_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptoui_i32_i16_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i16
-; CHECK-NEXT: ret i16 [[CONV_1]]
-;
- %conv = fptoui half %x to i32
- %conv.1 = trunc i32 %conv to i16
- ret i16 %conv.1
-}
+; Wider final type is ok.
-; TODO: i17 is not explored.
define i17 @half_fptoui_i32_i17(half %x) {
; CHECK-LABEL: @half_fptoui_i32_i17(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i17
-; CHECK-NEXT: ret i17 [[CONV_1]]
+; CHECK-NEXT: [[I:%.*]] = fptoui half [[X:%.*]] to i32
+; CHECK-NEXT: [[R:%.*]] = trunc i32 [[I]] to i17
+; CHECK-NEXT: ret i17 [[R]]
;
- %conv = fptoui half %x to i32
- %conv.1 = trunc i32 %conv to i17
- ret i17 %conv.1
+ %i = fptoui half %x to i32
+ %r = trunc i32 %i to i17
+ ret i17 %r
}
-; TODO: i17 is not explored.
-define i17 @half_fptoui_i32_i17_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptoui_i32_i17_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i17
-; CHECK-NEXT: ret i17 [[CONV_1]]
-;
- %conv = fptoui half %x to i32
- %conv.1 = trunc i32 %conv to i17
- ret i17 %conv.1
-}
+; Vectors work too.
define <4 x i16> @half_fptoui_4xi32_4xi16(<4 x half> %x) {
; CHECK-LABEL: @half_fptoui_4xi32_4xi16(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui <4 x half> [[X:%.*]] to <4 x i32>
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc <4 x i32> [[CONV]] to <4 x i16>
-; CHECK-NEXT: ret <4 x i16> [[CONV_1]]
-;
- %conv = fptoui <4 x half> %x to <4 x i32>
- %conv.1 = trunc <4 x i32> %conv to <4 x i16>
- ret <4 x i16> %conv.1
-}
-
-define <4 x i16> @half_fptoui_4xi32_4xi16_noundef(<4 x half> noundef %x) {
-; CHECK-LABEL: @half_fptoui_4xi32_4xi16_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui <4 x half> [[X:%.*]] to <4 x i32>
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc <4 x i32> [[CONV]] to <4 x i16>
-; CHECK-NEXT: ret <4 x i16> [[CONV_1]]
-;
- %conv = fptoui <4 x half> %x to <4 x i32>
- %conv.1 = trunc <4 x i32> %conv to <4 x i16>
- ret <4 x i16> %conv.1
-}
-
-; Negative test.
-define i31 @float_fptoui_i64_i31(float %x) {
-; CHECK-LABEL: @float_fptoui_i64_i31(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i31
-; CHECK-NEXT: ret i31 [[CONV_1]]
-;
- %conv = fptoui float %x to i64
- %conv.1 = trunc i64 %conv to i31
- ret i31 %conv.1
-}
-
-; Negative test.
-define i31 @float_fptoui_i64_i31_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptoui_i64_i31_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i31
-; CHECK-NEXT: ret i31 [[CONV_1]]
-;
- %conv = fptoui float %x to i64
- %conv.1 = trunc i64 %conv to i31
- ret i31 %conv.1
-}
-
-; Negative test.
-define i32 @float_fptoui_i64_i32(float %x) {
-; CHECK-LABEL: @float_fptoui_i64_i32(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i32
-; CHECK-NEXT: ret i32 [[CONV_1]]
-;
- %conv = fptoui float %x to i64
- %conv.1 = trunc i64 %conv to i32
- ret i32 %conv.1
-}
-
-; Negative test.
-define i32 @float_fptoui_i64_i32_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptoui_i64_i32_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i32
-; CHECK-NEXT: ret i32 [[CONV_1]]
-;
- %conv = fptoui float %x to i64
- %conv.1 = trunc i64 %conv to i32
- ret i32 %conv.1
-}
-
-define i33 @float_fptoui_i64_i33(float %x) {
-; CHECK-LABEL: @float_fptoui_i64_i33(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i33
-; CHECK-NEXT: ret i33 [[CONV_1]]
-;
- %conv = fptoui float %x to i64
- %conv.1 = trunc i64 %conv to i33
- ret i33 %conv.1
-}
-
-define i33 @float_fptoui_i64_i33_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptoui_i64_i33_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i33
-; CHECK-NEXT: ret i33 [[CONV_1]]
-;
- %conv = fptoui float %x to i64
- %conv.1 = trunc i64 %conv to i33
- ret i33 %conv.1
-}
-
-define i64 @float_fptoui_i128_i64(float %x) {
-; CHECK-LABEL: @float_fptoui_i128_i64(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i128
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i128 [[CONV]] to i64
-; CHECK-NEXT: ret i64 [[CONV_1]]
-;
- %conv = fptoui float %x to i128
- %conv.1 = trunc i128 %conv to i64
- ret i64 %conv.1
-}
-
-define i64 @float_fptoui_i128_i64_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptoui_i128_i64_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptoui float [[X:%.*]] to i128
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i128 [[CONV]] to i64
-; CHECK-NEXT: ret i64 [[CONV_1]]
-;
- %conv = fptoui float %x to i128
- %conv.1 = trunc i128 %conv to i64
- ret i64 %conv.1
-}
-
-; Negative test.
-define i15 @half_fptosi_i32_i15(half %x) {
-; CHECK-LABEL: @half_fptosi_i32_i15(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i15
-; CHECK-NEXT: ret i15 [[CONV_1]]
-;
- %conv = fptosi half %x to i32
- %conv.1 = trunc i32 %conv to i15
- ret i15 %conv.1
-}
-
-; Negative test.
-define i15 @half_fptosi_i32_i15_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptosi_i32_i15_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i15
-; CHECK-NEXT: ret i15 [[CONV_1]]
-;
- %conv = fptosi half %x to i32
- %conv.1 = trunc i32 %conv to i15
- ret i15 %conv.1
-}
-
-; Negative test.
-define i16 @half_fptosi_i32_i16(half %x) {
-; CHECK-LABEL: @half_fptosi_i32_i16(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i16
-; CHECK-NEXT: ret i16 [[CONV_1]]
-;
- %conv = fptosi half %x to i32
- %conv.1 = trunc i32 %conv to i16
- ret i16 %conv.1
-}
-
-; Negative test.
-define i16 @half_fptosi_i32_i16_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptosi_i32_i16_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i16
-; CHECK-NEXT: ret i16 [[CONV_1]]
-;
- %conv = fptosi half %x to i32
- %conv.1 = trunc i32 %conv to i16
- ret i16 %conv.1
-}
-
-; TODO: i17 isn't explored.
-define i17 @half_fptosi_i32_i17(half %x) {
-; CHECK-LABEL: @half_fptosi_i32_i17(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i17
-; CHECK-NEXT: ret i17 [[CONV_1]]
+; CHECK-NEXT: [[I:%.*]] = fptoui <4 x half> [[X:%.*]] to <4 x i32>
+; CHECK-NEXT: [[R:%.*]] = trunc <4 x i32> [[I]] to <4 x i16>
+; CHECK-NEXT: ret <4 x i16> [[R]]
;
- %conv = fptosi half %x to i32
- %conv.1 = trunc i32 %conv to i17
- ret i17 %conv.1
+ %i = fptoui <4 x half> %x to <4 x i32>
+ %r = trunc <4 x i32> %i to <4 x i16>
+ ret <4 x i16> %r
}
-; TODO: i17 isn't explored.
-define i17 @half_fptosi_i32_i17_noundef(half noundef %x) {
-; CHECK-LABEL: @half_fptosi_i32_i17_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[X:%.*]] to i32
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i32 [[CONV]] to i17
-; CHECK-NEXT: ret i17 [[CONV_1]]
+define i128 @bfloat_fptoui_i129_i128(bfloat %x) {
+; CHECK-LABEL: @bfloat_fptoui_i129_i128(
+; CHECK-NEXT: [[I:%.*]] = fptoui bfloat [[X:%.*]] to i129
+; CHECK-NEXT: [[R:%.*]] = trunc i129 [[I]] to i128
+; CHECK-NEXT: ret i128 [[R]]
;
- %conv = fptosi half %x to i32
- %conv.1 = trunc i32 %conv to i17
- ret i17 %conv.1
+ %i = fptoui bfloat %x to i129
+ %r = trunc i129 %i to i128
+ ret i128 %r
}
-; Negative test.
-define <4 x i16> @half_fptosi_4xi32_4xi16(<4 x half> %x) {
-; CHECK-LABEL: @half_fptosi_4xi32_4xi16(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi <4 x half> [[X:%.*]] to <4 x i32>
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc <4 x i32> [[CONV]] to <4 x i16>
-; CHECK-NEXT: ret <4 x i16> [[CONV_1]]
-;
- %conv = fptosi <4 x half> %x to <4 x i32>
- %conv.1 = trunc <4 x i32> %conv to <4 x i16>
- ret <4 x i16> %conv.1
-}
+; Negative test - not enough bits to hold max bfloat value (2**127 * (2 − 2**−7))
-; Negative test.
-define <4 x i16> @half_fptosi_4xi32_4xi16_noundef(<4 x half> noundef %x) {
-; CHECK-LABEL: @half_fptosi_4xi32_4xi16_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi <4 x half> [[X:%.*]] to <4 x i32>
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc <4 x i32> [[CONV]] to <4 x i16>
-; CHECK-NEXT: ret <4 x i16> [[CONV_1]]
+define i127 @bfloat_fptoui_i128_i127(bfloat %x) {
+; CHECK-LABEL: @bfloat_fptoui_i128_i127(
+; CHECK-NEXT: [[I:%.*]] = fptoui bfloat [[X:%.*]] to i128
+; CHECK-NEXT: [[R:%.*]] = trunc i128 [[I]] to i127
+; CHECK-NEXT: ret i127 [[R]]
;
- %conv = fptosi <4 x half> %x to <4 x i32>
- %conv.1 = trunc <4 x i32> %conv to <4 x i16>
- ret <4 x i16> %conv.1
+ %i = fptoui bfloat %x to i128
+ %r = trunc i128 %i to i127
+ ret i127 %r
}
-define <4 x i32> @half_fptosi_4xi64_4xi32(<4 x half> %x) {
-; CHECK-LABEL: @half_fptosi_4xi64_4xi32(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi <4 x half> [[X:%.*]] to <4 x i64>
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc <4 x i64> [[CONV]] to <4 x i32>
-; CHECK-NEXT: ret <4 x i32> [[CONV_1]]
+define i128 @float_fptoui_i129_i128(float %x) {
+; CHECK-LABEL: @float_fptoui_i129_i128(
+; CHECK-NEXT: [[I:%.*]] = fptoui float [[X:%.*]] to i129
+; CHECK-NEXT: [[R:%.*]] = trunc i129 [[I]] to i128
+; CHECK-NEXT: ret i128 [[R]]
;
- %conv = fptosi <4 x half> %x to <4 x i64>
- %conv.1 = trunc <4 x i64> %conv to <4 x i32>
- ret <4 x i32> %conv.1
+ %i = fptoui float %x to i129
+ %r = trunc i129 %i to i128
+ ret i128 %r
}
-; Negative test.
-define i31 @float_fptosi_i64_i31(float %x) {
-; CHECK-LABEL: @float_fptosi_i64_i31(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i31
-; CHECK-NEXT: ret i31 [[CONV_1]]
-;
- %conv = fptosi float %x to i64
- %conv.1 = trunc i64 %conv to i31
- ret i31 %conv.1
-}
-
-; Negative test.
-define i31 @float_fptosi_i64_i31_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptosi_i64_i31_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i31
-; CHECK-NEXT: ret i31 [[CONV_1]]
-;
- %conv = fptosi float %x to i64
- %conv.1 = trunc i64 %conv to i31
- ret i31 %conv.1
-}
+; Negative test - not enough bits to hold max float value (2**127 * (2 − 2**−23))
-; Negative test.
-define i32 @float_fptosi_i64_i32(float %x) {
-; CHECK-LABEL: @float_fptosi_i64_i32(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i32
-; CHECK-NEXT: ret i32 [[CONV_1]]
+define i127 @float_fptoui_i128_i127(float %x) {
+; CHECK-LABEL: @float_fptoui_i128_i127(
+; CHECK-NEXT: [[I:%.*]] = fptoui float [[X:%.*]] to i128
+; CHECK-NEXT: [[R:%.*]] = trunc i128 [[I]] to i127
+; CHECK-NEXT: ret i127 [[R]]
;
- %conv = fptosi float %x to i64
- %conv.1 = trunc i64 %conv to i32
- ret i32 %conv.1
+ %i = fptoui float %x to i128
+ %r = trunc i128 %i to i127
+ ret i127 %r
}
-; Negative test.
-define i32 @float_fptosi_i64_i32_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptosi_i64_i32_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i32
-; CHECK-NEXT: ret i32 [[CONV_1]]
+define i1024 @float_fptoui_i1025_i1024(double %x) {
+; CHECK-LABEL: @float_fptoui_i1025_i1024(
+; CHECK-NEXT: [[I:%.*]] = fptoui double [[X:%.*]] to i1025
+; CHECK-NEXT: [[R:%.*]] = trunc i1025 [[I]] to i1024
+; CHECK-NEXT: ret i1024 [[R]]
;
- %conv = fptosi float %x to i64
- %conv.1 = trunc i64 %conv to i32
- ret i32 %conv.1
+ %i = fptoui double %x to i1025
+ %r = trunc i1025 %i to i1024
+ ret i1024 %r
}
-define i33 @float_fptosi_i64_i33(float %x) {
-; CHECK-LABEL: @float_fptosi_i64_i33(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i33
-; CHECK-NEXT: ret i33 [[CONV_1]]
-;
- %conv = fptosi float %x to i64
- %conv.1 = trunc i64 %conv to i33
- ret i33 %conv.1
-}
-
-define i33 @float_fptosi_i64_i33_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptosi_i64_i33_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i64
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i64 [[CONV]] to i33
-; CHECK-NEXT: ret i33 [[CONV_1]]
-;
- %conv = fptosi float %x to i64
- %conv.1 = trunc i64 %conv to i33
- ret i33 %conv.1
-}
-
-define i64 @float_fptosi_i128_i64(float %x) {
-; CHECK-LABEL: @float_fptosi_i128_i64(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i128
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i128 [[CONV]] to i64
-; CHECK-NEXT: ret i64 [[CONV_1]]
-;
- %conv = fptosi float %x to i128
- %conv.1 = trunc i128 %conv to i64
- ret i64 %conv.1
-}
+; Negative test - not enough bits to hold max double value (2**1023 * (2 − 2**−52))
-define i64 @float_fptosi_i128_i64_noundef(float noundef %x) {
-; CHECK-LABEL: @float_fptosi_i128_i64_noundef(
-; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[X:%.*]] to i128
-; CHECK-NEXT: [[CONV_1:%.*]] = trunc i128 [[CONV]] to i64
-; CHECK-NEXT: ret i64 [[CONV_1]]
+define i1023 @float_fptoui_i1024_i1023(float %x) {
+; CHECK-LABEL: @float_fptoui_i1024_i1023(
+; CHECK-NEXT: [[I:%.*]] = fptoui float [[X:%.*]] to i1024
+; CHECK-NEXT: [[R:%.*]] = trunc i1024 [[I]] to i1023
+; CHECK-NEXT: ret i1023 [[R]]
;
- %conv = fptosi float %x to i128
- %conv.1 = trunc i128 %conv to i64
- ret i64 %conv.1
+ %i = fptoui float %x to i1024
+ %r = trunc i1024 %i to i1023
+ ret i1023 %r
}
More information about the llvm-commits
mailing list