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(ptr %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>, ptr %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(ptr 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, ptr %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(ptr 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 = load x86_mmx, ptr %ptr, align 8
86 %1 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %0, i8 -24)
87 %2 = bitcast x86_mmx %1 to <4 x i16>
88 %3 = bitcast <4 x i16> %2 to <1 x i64>
89 %4 = extractelement <1 x i64> %3, i32 0
90 %5 = bitcast i64 %4 to <2 x i32>
91 %6 = extractelement <2 x i32> %5, i32 0
92 tail call void @llvm.x86.mmx.emms()
96 define i32 @test3(x86_mmx %a) nounwind {
99 ; X32-NEXT: movd %mm0, %eax
104 ; X64-NEXT: movd %mm0, %eax
106 %tmp0 = bitcast x86_mmx %a to <2 x i32>
107 %tmp1 = extractelement <2 x i32> %tmp0, i32 0
111 ; Verify we don't muck with extractelts from the upper lane.
112 define i32 @test4(x86_mmx %a) nounwind {
115 ; X32-NEXT: movq2dq %mm0, %xmm0
116 ; X32-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,1,1]
117 ; X32-NEXT: movd %xmm0, %eax
122 ; X64-NEXT: movq2dq %mm0, %xmm0
123 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,1,1]
124 ; X64-NEXT: movd %xmm0, %eax
126 %tmp0 = bitcast x86_mmx %a to <2 x i32>
127 %tmp1 = extractelement <2 x i32> %tmp0, i32 1
131 declare x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx, i8)
132 declare void @llvm.x86.mmx.emms()