1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown -mattr=+mmx,+sse2 | FileCheck %s --check-prefix=X32
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+mmx,+sse2 | FileCheck %s --check-prefix=X64
5 define i32 @test0(<1 x i64>* %v4) nounwind {
7 ; X32: # %bb.0: # %entry
8 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; X32-NEXT: pshufw $238, (%eax), %mm0 # mm0 = mem[2,3,2,3]
10 ; X32-NEXT: movd %mm0, %eax
11 ; X32-NEXT: addl $32, %eax
15 ; X64: # %bb.0: # %entry
16 ; X64-NEXT: pshufw $238, (%rdi), %mm0 # mm0 = mem[2,3,2,3]
17 ; X64-NEXT: movd %mm0, %eax
18 ; X64-NEXT: addl $32, %eax
21 %v5 = load <1 x i64>, <1 x i64>* %v4, align 8
22 %v12 = bitcast <1 x i64> %v5 to <4 x i16>
23 %v13 = bitcast <4 x i16> %v12 to x86_mmx
24 %v14 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %v13, i8 -18)
25 %v15 = bitcast x86_mmx %v14 to <4 x i16>
26 %v16 = bitcast <4 x i16> %v15 to <1 x i64>
27 %v17 = extractelement <1 x i64> %v16, i32 0
28 %v18 = bitcast i64 %v17 to <2 x i32>
29 %v19 = extractelement <2 x i32> %v18, i32 0
30 %v20 = add i32 %v19, 32
34 define i32 @test1(i32* nocapture readonly %ptr) nounwind {
36 ; X32: # %bb.0: # %entry
37 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
38 ; X32-NEXT: movd (%eax), %mm0
39 ; X32-NEXT: pshufw $232, %mm0, %mm0 # mm0 = mm0[0,2,2,3]
40 ; X32-NEXT: movd %mm0, %eax
45 ; X64: # %bb.0: # %entry
46 ; X64-NEXT: movd (%rdi), %mm0
47 ; X64-NEXT: pshufw $232, %mm0, %mm0 # mm0 = mm0[0,2,2,3]
48 ; X64-NEXT: movd %mm0, %eax
52 %0 = load i32, i32* %ptr, align 4
53 %1 = insertelement <2 x i32> undef, i32 %0, i32 0
54 %2 = insertelement <2 x i32> %1, i32 0, i32 1
55 %3 = bitcast <2 x i32> %2 to x86_mmx
56 %4 = bitcast x86_mmx %3 to i64
57 %5 = bitcast i64 %4 to <4 x i16>
58 %6 = bitcast <4 x i16> %5 to x86_mmx
59 %7 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %6, i8 -24)
60 %8 = bitcast x86_mmx %7 to <4 x i16>
61 %9 = bitcast <4 x i16> %8 to <1 x i64>
62 %10 = extractelement <1 x i64> %9, i32 0
63 %11 = bitcast i64 %10 to <2 x i32>
64 %12 = extractelement <2 x i32> %11, i32 0
65 tail call void @llvm.x86.mmx.emms()
69 define i32 @test2(i32* nocapture readonly %ptr) nounwind {
71 ; X32: # %bb.0: # %entry
72 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
73 ; X32-NEXT: pshufw $232, (%eax), %mm0 # mm0 = mem[0,2,2,3]
74 ; X32-NEXT: movd %mm0, %eax
79 ; X64: # %bb.0: # %entry
80 ; X64-NEXT: pshufw $232, (%rdi), %mm0 # mm0 = mem[0,2,2,3]
81 ; X64-NEXT: movd %mm0, %eax
85 %0 = bitcast i32* %ptr to x86_mmx*
86 %1 = load x86_mmx, x86_mmx* %0, align 8
87 %2 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %1, i8 -24)
88 %3 = bitcast x86_mmx %2 to <4 x i16>
89 %4 = bitcast <4 x i16> %3 to <1 x i64>
90 %5 = extractelement <1 x i64> %4, i32 0
91 %6 = bitcast i64 %5 to <2 x i32>
92 %7 = extractelement <2 x i32> %6, i32 0
93 tail call void @llvm.x86.mmx.emms()
97 define i32 @test3(x86_mmx %a) nounwind {
100 ; X32-NEXT: movd %mm0, %eax
105 ; X64-NEXT: movd %mm0, %eax
107 %tmp0 = bitcast x86_mmx %a to <2 x i32>
108 %tmp1 = extractelement <2 x i32> %tmp0, i32 0
112 ; Verify we don't muck with extractelts from the upper lane.
113 define i32 @test4(x86_mmx %a) nounwind {
116 ; X32-NEXT: pushl %ebp
117 ; X32-NEXT: movl %esp, %ebp
118 ; X32-NEXT: andl $-8, %esp
119 ; X32-NEXT: subl $8, %esp
120 ; X32-NEXT: movq %mm0, (%esp)
121 ; X32-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
122 ; X32-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,1,0,1]
123 ; X32-NEXT: movd %xmm0, %eax
124 ; X32-NEXT: movl %ebp, %esp
125 ; X32-NEXT: popl %ebp
130 ; X64-NEXT: movq %mm0, -{{[0-9]+}}(%rsp)
131 ; X64-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
132 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,3,0,1]
133 ; X64-NEXT: movd %xmm0, %eax
135 %tmp0 = bitcast x86_mmx %a to <2 x i32>
136 %tmp1 = extractelement <2 x i32> %tmp0, i32 1
140 declare x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx, i8)
141 declare void @llvm.x86.mmx.emms()