1 ; RUN: opt < %s -constprop -S | FileCheck %s
2 ; REQUIRES: x86-registered-target
4 define i1 @test_sse_cvts_exact() nounwind readnone {
5 ; CHECK-LABEL: @test_sse_cvts_exact(
9 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> <float 3.0, float undef, float undef, float undef>) nounwind
10 %i1 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> <float 3.0, float undef, float undef, float undef>) nounwind
11 %i2 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> <double 7.0, double undef>) nounwind
12 %i3 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> <double 7.0, double undef>) nounwind
13 %sum02 = add i32 %i0, %i2
14 %sum13 = add i64 %i1, %i3
15 %cmp02 = icmp eq i32 %sum02, 10
16 %cmp13 = icmp eq i64 %sum13, 10
17 %b = and i1 %cmp02, %cmp13
21 ; Inexact values should not fold as they are dependent on rounding mode
22 define i1 @test_sse_cvts_inexact() nounwind readnone {
23 ; CHECK-LABEL: @test_sse_cvts_inexact(
29 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
30 %i1 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
31 %i2 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> <double 1.75, double undef>) nounwind
32 %i3 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> <double 1.75, double undef>) nounwind
33 %sum02 = add i32 %i0, %i2
34 %sum13 = add i64 %i1, %i3
35 %cmp02 = icmp eq i32 %sum02, 4
36 %cmp13 = icmp eq i64 %sum13, 4
37 %b = and i1 %cmp02, %cmp13
41 ; FLT_MAX/DBL_MAX should not fold
42 define i1 @test_sse_cvts_max() nounwind readnone {
43 ; CHECK-LABEL: @test_sse_cvts_max(
49 %fm = bitcast <4 x i32> <i32 2139095039, i32 undef, i32 undef, i32 undef> to <4 x float>
50 %dm = bitcast <2 x i64> <i64 9218868437227405311, i64 undef> to <2 x double>
51 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> %fm) nounwind
52 %i1 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> %fm) nounwind
53 %i2 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> %dm) nounwind
54 %i3 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> %dm) nounwind
55 %sum02 = add i32 %i0, %i2
56 %sum13 = add i64 %i1, %i3
57 %sum02.sext = sext i32 %sum02 to i64
58 %b = icmp eq i64 %sum02.sext, %sum13
63 define i1 @test_sse_cvts_inf() nounwind readnone {
64 ; CHECK-LABEL: @test_sse_cvts_inf(
70 %fm = bitcast <4 x i32> <i32 2139095040, i32 undef, i32 undef, i32 undef> to <4 x float>
71 %dm = bitcast <2 x i64> <i64 9218868437227405312, i64 undef> to <2 x double>
72 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> %fm) nounwind
73 %i1 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> %fm) nounwind
74 %i2 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> %dm) nounwind
75 %i3 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> %dm) nounwind
76 %sum02 = add i32 %i0, %i2
77 %sum13 = add i64 %i1, %i3
78 %sum02.sext = sext i32 %sum02 to i64
79 %b = icmp eq i64 %sum02.sext, %sum13
84 define i1 @test_sse_cvts_nan() nounwind readnone {
85 ; CHECK-LABEL: @test_sse_cvts_nan(
91 %fm = bitcast <4 x i32> <i32 2143289344, i32 undef, i32 undef, i32 undef> to <4 x float>
92 %dm = bitcast <2 x i64> <i64 9221120237041090560, i64 undef> to <2 x double>
93 %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> %fm) nounwind
94 %i1 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> %fm) nounwind
95 %i2 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> %dm) nounwind
96 %i3 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> %dm) nounwind
97 %sum02 = add i32 %i0, %i2
98 %sum13 = add i64 %i1, %i3
99 %sum02.sext = sext i32 %sum02 to i64
100 %b = icmp eq i64 %sum02.sext, %sum13
104 define i1 @test_sse_cvtts_exact() nounwind readnone {
105 ; CHECK-LABEL: @test_sse_cvtts_exact(
109 %i0 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> <float 3.0, float undef, float undef, float undef>) nounwind
110 %i1 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> <float 3.0, float undef, float undef, float undef>) nounwind
111 %i2 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> <double 7.0, double undef>) nounwind
112 %i3 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> <double 7.0, double undef>) nounwind
113 %sum02 = add i32 %i0, %i2
114 %sum13 = add i64 %i1, %i3
115 %cmp02 = icmp eq i32 %sum02, 10
116 %cmp13 = icmp eq i64 %sum13, 10
117 %b = and i1 %cmp02, %cmp13
121 define i1 @test_sse_cvtts_inexact() nounwind readnone {
122 ; CHECK-LABEL: @test_sse_cvtts_inexact(
126 %i0 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
127 %i1 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
128 %i2 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> <double 1.75, double undef>) nounwind
129 %i3 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> <double 1.75, double undef>) nounwind
130 %sum02 = add i32 %i0, %i2
131 %sum13 = add i64 %i1, %i3
132 %cmp02 = icmp eq i32 %sum02, 2
133 %cmp13 = icmp eq i64 %sum13, 2
134 %b = and i1 %cmp02, %cmp13
138 ; FLT_MAX/DBL_MAX should not fold
139 define i1 @test_sse_cvtts_max() nounwind readnone {
140 ; CHECK-LABEL: @test_sse_cvtts_max(
146 %fm = bitcast <4 x i32> <i32 2139095039, i32 undef, i32 undef, i32 undef> to <4 x float>
147 %dm = bitcast <2 x i64> <i64 9218868437227405311, i64 undef> to <2 x double>
148 %i0 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> %fm) nounwind
149 %i1 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> %fm) nounwind
150 %i2 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> %dm) nounwind
151 %i3 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> %dm) nounwind
152 %sum02 = add i32 %i0, %i2
153 %sum13 = add i64 %i1, %i3
154 %sum02.sext = sext i32 %sum02 to i64
155 %b = icmp eq i64 %sum02.sext, %sum13
159 ; INF should not fold
160 define i1 @test_sse_cvtts_inf() nounwind readnone {
161 ; CHECK-LABEL: @test_sse_cvtts_inf(
167 %fm = bitcast <4 x i32> <i32 2139095040, i32 undef, i32 undef, i32 undef> to <4 x float>
168 %dm = bitcast <2 x i64> <i64 9218868437227405312, i64 undef> to <2 x double>
169 %i0 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> %fm) nounwind
170 %i1 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> %fm) nounwind
171 %i2 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> %dm) nounwind
172 %i3 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> %dm) nounwind
173 %sum02 = add i32 %i0, %i2
174 %sum13 = add i64 %i1, %i3
175 %sum02.sext = sext i32 %sum02 to i64
176 %b = icmp eq i64 %sum02.sext, %sum13
180 ; NAN should not fold
181 define i1 @test_sse_cvtts_nan() nounwind readnone {
182 ; CHECK-LABEL: @test_sse_cvtts_nan(
188 %fm = bitcast <4 x i32> <i32 2143289344, i32 undef, i32 undef, i32 undef> to <4 x float>
189 %dm = bitcast <2 x i64> <i64 9221120237041090560, i64 undef> to <2 x double>
190 %i0 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> %fm) nounwind
191 %i1 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> %fm) nounwind
192 %i2 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> %dm) nounwind
193 %i3 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> %dm) nounwind
194 %sum02 = add i32 %i0, %i2
195 %sum13 = add i64 %i1, %i3
196 %sum02.sext = sext i32 %sum02 to i64
197 %b = icmp eq i64 %sum02.sext, %sum13
201 declare i32 @llvm.x86.sse.cvtss2si(<4 x float>) nounwind readnone
202 declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) nounwind readnone
203 declare i64 @llvm.x86.sse.cvtss2si64(<4 x float>) nounwind readnone
204 declare i64 @llvm.x86.sse.cvttss2si64(<4 x float>) nounwind readnone
205 declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone
206 declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone
207 declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone
208 declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone