1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=aggressive-instcombine -mtriple x86_64-none-eabi -mattr=avx2 -S | FileCheck %s
4 define i64 @f32_i32(float %in) {
5 ; CHECK-LABEL: @f32_i32(
6 ; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[IN:%.*]] to i64
7 ; CHECK-NEXT: [[MIN:%.*]] = call i64 @llvm.smin.i64(i64 [[CONV]], i64 2147483647)
8 ; CHECK-NEXT: [[MAX:%.*]] = call i64 @llvm.smax.i64(i64 [[MIN]], i64 -2147483648)
9 ; CHECK-NEXT: ret i64 [[MAX]]
11 %conv = fptosi float %in to i64
12 %min = call i64 @llvm.smin.i64(i64 %conv, i64 2147483647)
13 %max = call i64 @llvm.smax.i64(i64 %min, i64 -2147483648)
17 define i64 @f32_i31(float %in) {
18 ; CHECK-LABEL: @f32_i31(
19 ; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[IN:%.*]] to i64
20 ; CHECK-NEXT: [[MIN:%.*]] = call i64 @llvm.smin.i64(i64 [[CONV]], i64 1073741823)
21 ; CHECK-NEXT: [[MAX:%.*]] = call i64 @llvm.smax.i64(i64 [[MIN]], i64 -1073741824)
22 ; CHECK-NEXT: ret i64 [[MAX]]
24 %conv = fptosi float %in to i64
25 %min = call i64 @llvm.smin.i64(i64 %conv, i64 1073741823)
26 %max = call i64 @llvm.smax.i64(i64 %min, i64 -1073741824)
30 define i32 @f32_i16(float %in) {
31 ; CHECK-LABEL: @f32_i16(
32 ; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[IN:%.*]] to i32
33 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[CONV]], i32 32767)
34 ; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.smax.i32(i32 [[MIN]], i32 -32768)
35 ; CHECK-NEXT: ret i32 [[MAX]]
37 %conv = fptosi float %in to i32
38 %min = call i32 @llvm.smin.i32(i32 %conv, i32 32767)
39 %max = call i32 @llvm.smax.i32(i32 %min, i32 -32768)
43 define i32 @f32_i8(float %in) {
44 ; CHECK-LABEL: @f32_i8(
45 ; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[IN:%.*]] to i32
46 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[CONV]], i32 127)
47 ; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.smax.i32(i32 [[MIN]], i32 -128)
48 ; CHECK-NEXT: ret i32 [[MAX]]
50 %conv = fptosi float %in to i32
51 %min = call i32 @llvm.smin.i32(i32 %conv, i32 127)
52 %max = call i32 @llvm.smax.i32(i32 %min, i32 -128)
56 define i64 @f64_i32(double %in) {
57 ; CHECK-LABEL: @f64_i32(
58 ; CHECK-NEXT: [[CONV:%.*]] = fptosi double [[IN:%.*]] to i64
59 ; CHECK-NEXT: [[MIN:%.*]] = call i64 @llvm.smin.i64(i64 [[CONV]], i64 2147483647)
60 ; CHECK-NEXT: [[MAX:%.*]] = call i64 @llvm.smax.i64(i64 [[MIN]], i64 -2147483648)
61 ; CHECK-NEXT: ret i64 [[MAX]]
63 %conv = fptosi double %in to i64
64 %min = call i64 @llvm.smin.i64(i64 %conv, i64 2147483647)
65 %max = call i64 @llvm.smax.i64(i64 %min, i64 -2147483648)
69 define i64 @f64_i31(double %in) {
70 ; CHECK-LABEL: @f64_i31(
71 ; CHECK-NEXT: [[CONV:%.*]] = fptosi double [[IN:%.*]] to i64
72 ; CHECK-NEXT: [[MIN:%.*]] = call i64 @llvm.smin.i64(i64 [[CONV]], i64 1073741823)
73 ; CHECK-NEXT: [[MAX:%.*]] = call i64 @llvm.smax.i64(i64 [[MIN]], i64 -1073741824)
74 ; CHECK-NEXT: ret i64 [[MAX]]
76 %conv = fptosi double %in to i64
77 %min = call i64 @llvm.smin.i64(i64 %conv, i64 1073741823)
78 %max = call i64 @llvm.smax.i64(i64 %min, i64 -1073741824)
82 define i32 @f64_i16(double %in) {
83 ; CHECK-LABEL: @f64_i16(
84 ; CHECK-NEXT: [[CONV:%.*]] = fptosi double [[IN:%.*]] to i32
85 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[CONV]], i32 32767)
86 ; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.smax.i32(i32 [[MIN]], i32 -32768)
87 ; CHECK-NEXT: ret i32 [[MAX]]
89 %conv = fptosi double %in to i32
90 %min = call i32 @llvm.smin.i32(i32 %conv, i32 32767)
91 %max = call i32 @llvm.smax.i32(i32 %min, i32 -32768)
95 define i64 @f16_i32(half %in) {
96 ; CHECK-LABEL: @f16_i32(
97 ; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[IN:%.*]] to i64
98 ; CHECK-NEXT: [[MIN:%.*]] = call i64 @llvm.smin.i64(i64 [[CONV]], i64 2147483647)
99 ; CHECK-NEXT: [[MAX:%.*]] = call i64 @llvm.smax.i64(i64 [[MIN]], i64 -2147483648)
100 ; CHECK-NEXT: ret i64 [[MAX]]
102 %conv = fptosi half %in to i64
103 %min = call i64 @llvm.smin.i64(i64 %conv, i64 2147483647)
104 %max = call i64 @llvm.smax.i64(i64 %min, i64 -2147483648)
108 define i64 @f16_i31(half %in) {
109 ; CHECK-LABEL: @f16_i31(
110 ; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[IN:%.*]] to i64
111 ; CHECK-NEXT: [[MIN:%.*]] = call i64 @llvm.smin.i64(i64 [[CONV]], i64 1073741823)
112 ; CHECK-NEXT: [[MAX:%.*]] = call i64 @llvm.smax.i64(i64 [[MIN]], i64 -1073741824)
113 ; CHECK-NEXT: ret i64 [[MAX]]
115 %conv = fptosi half %in to i64
116 %min = call i64 @llvm.smin.i64(i64 %conv, i64 1073741823)
117 %max = call i64 @llvm.smax.i64(i64 %min, i64 -1073741824)
121 define i32 @f16_i16(half %in) {
122 ; CHECK-LABEL: @f16_i16(
123 ; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[IN:%.*]] to i32
124 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[CONV]], i32 32767)
125 ; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.smax.i32(i32 [[MIN]], i32 -32768)
126 ; CHECK-NEXT: ret i32 [[MAX]]
128 %conv = fptosi half %in to i32
129 %min = call i32 @llvm.smin.i32(i32 %conv, i32 32767)
130 %max = call i32 @llvm.smax.i32(i32 %min, i32 -32768)
134 define i32 @f16_i8(half %in) {
135 ; CHECK-LABEL: @f16_i8(
136 ; CHECK-NEXT: [[CONV:%.*]] = fptosi half [[IN:%.*]] to i32
137 ; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[CONV]], i32 127)
138 ; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.smax.i32(i32 [[MIN]], i32 -128)
139 ; CHECK-NEXT: ret i32 [[MAX]]
141 %conv = fptosi half %in to i32
142 %min = call i32 @llvm.smin.i32(i32 %conv, i32 127)
143 %max = call i32 @llvm.smax.i32(i32 %min, i32 -128)
147 define <4 x i64> @v4f32_i32(<4 x float> %in) {
148 ; CHECK-LABEL: @v4f32_i32(
149 ; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i32> @llvm.fptosi.sat.v4i32.v4f32(<4 x float> [[IN:%.*]])
150 ; CHECK-NEXT: [[TMP2:%.*]] = sext <4 x i32> [[TMP1]] to <4 x i64>
151 ; CHECK-NEXT: ret <4 x i64> [[TMP2]]
153 %conv = fptosi <4 x float> %in to <4 x i64>
154 %min = call <4 x i64> @llvm.smin.v4i64(<4 x i64> %conv, <4 x i64> <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>)
155 %max = call <4 x i64> @llvm.smax.v4i64(<4 x i64> %min, <4 x i64> <i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648>)
159 define <8 x i32> @v8f16_i16(<8 x half> %in) {
160 ; CHECK-LABEL: @v8f16_i16(
161 ; CHECK-NEXT: [[CONV:%.*]] = fptosi <8 x half> [[IN:%.*]] to <8 x i32>
162 ; CHECK-NEXT: [[MIN:%.*]] = call <8 x i32> @llvm.smin.v8i32(<8 x i32> [[CONV]], <8 x i32> <i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767>)
163 ; CHECK-NEXT: [[MAX:%.*]] = call <8 x i32> @llvm.smax.v8i32(<8 x i32> [[MIN]], <8 x i32> <i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768>)
164 ; CHECK-NEXT: ret <8 x i32> [[MAX]]
166 %conv = fptosi <8 x half> %in to <8 x i32>
167 %min = call <8 x i32> @llvm.smin.v8i32(<8 x i32> %conv, <8 x i32> <i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767>)
168 %max = call <8 x i32> @llvm.smax.v8i32(<8 x i32> %min, <8 x i32> <i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768>)
173 declare i64 @llvm.smin.i64(i64, i64)
174 declare i64 @llvm.smax.i64(i64, i64)
175 declare i32 @llvm.smin.i32(i32, i32)
176 declare i32 @llvm.smax.i32(i32, i32)
177 declare <2 x i64> @llvm.smin.v2i64(<2 x i64>, <2 x i64>)
178 declare <2 x i64> @llvm.smax.v2i64(<2 x i64>, <2 x i64>)
179 declare <4 x i64> @llvm.smin.v4i64(<4 x i64>, <4 x i64>)
180 declare <4 x i64> @llvm.smax.v4i64(<4 x i64>, <4 x i64>)
181 declare <8 x i64> @llvm.smin.v8i64(<8 x i64>, <8 x i64>)
182 declare <8 x i64> @llvm.smax.v8i64(<8 x i64>, <8 x i64>)
183 declare <4 x i32> @llvm.smin.v4i32(<4 x i32>, <4 x i32>)
184 declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>)
185 declare <8 x i32> @llvm.smin.v8i32(<8 x i32>, <8 x i32>)
186 declare <8 x i32> @llvm.smax.v8i32(<8 x i32>, <8 x i32>)