1; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
2
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone
7declare <2 x double> @llvm.x86.sse2.cvtsi2sd(<2 x double>, i32) nounwind readnone
8declare x86_mmx @llvm.x86.sse.cvtps2pi(<4 x float>) nounwind readnone
9
10; Single argument vector conversion.
11
12define i32 @test_cvtsd2si(<2 x double> %value) sanitize_memory {
13entry:
14  %0 = tail call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> %value)
15  ret i32 %0
16}
17
18; CHECK-LABEL: @test_cvtsd2si
19; CHECK: [[S:%[_01-9a-z]+]] = extractelement <2 x i64> {{.*}}, i32 0
20; CHECK: icmp ne {{.*}}[[S]], 0
21; CHECK: br
22; CHECK: call void @__msan_warning_noreturn
23; CHECK: call i32 @llvm.x86.sse2.cvtsd2si
24; CHECK: store i32 0, {{.*}} @__msan_retval_tls
25; CHECK: ret i32
26
27; Two-argument vector conversion.
28
29define <2 x double> @test_cvtsi2sd(i32 %a, double %b) sanitize_memory {
30entry:
31  %vec = insertelement <2 x double> undef, double %b, i32 1
32  %0 = tail call <2 x double> @llvm.x86.sse2.cvtsi2sd(<2 x double> %vec, i32 %a)
33  ret <2 x double> %0
34}
35
36; CHECK-LABEL: @test_cvtsi2sd
37; CHECK: [[Sa:%[_01-9a-z]+]] = load i32, i32* {{.*}} @__msan_param_tls
38; CHECK: [[Sout0:%[_01-9a-z]+]] = insertelement <2 x i64> <i64 -1, i64 -1>, i64 {{.*}}, i32 1
39; Clear low half of result shadow
40; CHECK: [[Sout:%[_01-9a-z]+]] = insertelement <2 x i64> {{.*}}[[Sout0]], i64 0, i32 0
41; Trap on %a shadow.
42; CHECK: icmp ne {{.*}}[[Sa]], 0
43; CHECK: br
44; CHECK: call void @__msan_warning_noreturn
45; CHECK: call <2 x double> @llvm.x86.sse2.cvtsi2sd
46; CHECK: store <2 x i64> {{.*}}[[Sout]], {{.*}} @__msan_retval_tls
47; CHECK: ret <2 x double>
48
49; x86_mmx packed vector conversion.
50
51define x86_mmx @test_cvtps2pi(<4 x float> %value) sanitize_memory {
52entry:
53  %0 = tail call x86_mmx @llvm.x86.sse.cvtps2pi(<4 x float> %value)
54  ret x86_mmx %0
55}
56
57; CHECK-LABEL: @test_cvtps2pi
58; CHECK: extractelement <4 x i32> {{.*}}, i32 0
59; CHECK: extractelement <4 x i32> {{.*}}, i32 1
60; CHECK: [[S:%[_01-9a-z]+]] = or i32
61; CHECK: icmp ne {{.*}}[[S]], 0
62; CHECK: br
63; CHECK: call void @__msan_warning_noreturn
64; CHECK: call x86_mmx @llvm.x86.sse.cvtps2pi
65; CHECK: store i64 0, {{.*}} @__msan_retval_tls
66; CHECK: ret x86_mmx
67