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 <4 x i32> @llvm.x86.sse2.pmadd.wd(<8 x i16>, <8 x i16>) nounwind readnone
7declare x86_mmx @llvm.x86.ssse3.pmadd.ub.sw(x86_mmx, x86_mmx) nounwind readnone
8declare <2 x i64> @llvm.x86.sse2.psad.bw(<16 x i8>, <16 x i8>) nounwind readnone
9declare x86_mmx @llvm.x86.mmx.psad.bw(x86_mmx, x86_mmx) nounwind readnone
10
11define <4 x i32> @Test_sse2_pmadd_wd(<8 x i16> %a, <8 x i16> %b) sanitize_memory {
12entry:
13  %c = tail call <4 x i32> @llvm.x86.sse2.pmadd.wd(<8 x i16> %a, <8 x i16> %b) nounwind
14  ret <4 x i32> %c
15}
16
17; CHECK-LABEL: @Test_sse2_pmadd_wd(
18; CHECK: or <8 x i16>
19; CHECK: bitcast <8 x i16> {{.*}} to <4 x i32>
20; CHECK: icmp ne <4 x i32> {{.*}}, zeroinitializer
21; CHECK: sext <4 x i1> {{.*}} to <4 x i32>
22; CHECK: ret <4 x i32>
23
24
25define x86_mmx @Test_ssse3_pmadd_ub_sw(x86_mmx %a, x86_mmx %b) sanitize_memory {
26entry:
27  %c = tail call x86_mmx @llvm.x86.ssse3.pmadd.ub.sw(x86_mmx %a, x86_mmx %b) nounwind
28  ret x86_mmx %c
29}
30
31; CHECK-LABEL: @Test_ssse3_pmadd_ub_sw(
32; CHECK: or i64
33; CHECK: bitcast i64 {{.*}} to <4 x i16>
34; CHECK: icmp ne <4 x i16> {{.*}}, zeroinitializer
35; CHECK: sext <4 x i1> {{.*}} to <4 x i16>
36; CHECK: bitcast <4 x i16> {{.*}} to i64
37; CHECK: ret x86_mmx
38
39
40define <2 x i64> @Test_x86_sse2_psad_bw(<16 x i8> %a, <16 x i8> %b) sanitize_memory {
41  %c = tail call <2 x i64> @llvm.x86.sse2.psad.bw(<16 x i8> %a, <16 x i8> %b)
42  ret <2 x i64> %c
43}
44
45; CHECK-LABEL: @Test_x86_sse2_psad_bw(
46; CHECK: or <16 x i8> {{.*}}, {{.*}}
47; CHECK: bitcast <16 x i8> {{.*}} to <2 x i64>
48; CHECK: icmp ne <2 x i64> {{.*}}, zeroinitializer
49; CHECK: sext <2 x i1> {{.*}} to <2 x i64>
50; CHECK: lshr <2 x i64> {{.*}}, <i64 48, i64 48>
51; CHECK: ret <2 x i64>
52
53
54define x86_mmx @Test_x86_mmx_psad_bw(x86_mmx %a, x86_mmx %b) sanitize_memory {
55entry:
56  %c = tail call x86_mmx @llvm.x86.mmx.psad.bw(x86_mmx %a, x86_mmx %b) nounwind
57  ret x86_mmx %c
58}
59
60; CHECK-LABEL: @Test_x86_mmx_psad_bw(
61; CHECK: or i64
62; CHECK: icmp ne i64
63; CHECK: sext i1 {{.*}} to i64
64; CHECK: lshr i64 {{.*}}, 48
65; CHECK: ret x86_mmx
66