19df059e2ec19b58ee4b6170f920dd10ea744d7b
[oota-llvm.git] / test / CodeGen / X86 / vec_extract-mmx.ll
1 ; RUN: llc < %s -mtriple=x86_64-darwin -x86-experimental-vector-widening-legalization -mattr=+mmx,+sse2 | FileCheck %s
2
3 define i32 @test0(<1 x i64>* %v4) {
4 ; CHECK-LABEL: test0:
5 ; CHECK:       ## BB#0:
6 ; CHECK-NEXT:    pshufw $238, (%rdi), %mm0
7 ; CHECK-NEXT:    movd %mm0, %eax
8 ; CHECK-NEXT:    addl $32, %eax
9 ; CHECK-NEXT:    retq
10   %v5 = load <1 x i64>* %v4, align 8
11   %v12 = bitcast <1 x i64> %v5 to <4 x i16>
12   %v13 = bitcast <4 x i16> %v12 to x86_mmx
13   %v14 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %v13, i8 -18)
14   %v15 = bitcast x86_mmx %v14 to <4 x i16>
15   %v16 = bitcast <4 x i16> %v15 to <1 x i64>
16   %v17 = extractelement <1 x i64> %v16, i32 0
17   %v18 = bitcast i64 %v17 to <2 x i32>
18   %v19 = extractelement <2 x i32> %v18, i32 0
19   %v20 = add i32 %v19, 32
20   ret i32 %v20
21 }
22
23 define i32 @test1(i32* nocapture readonly %ptr) {
24 ; CHECK-LABEL: test1:
25 ; CHECK:       ## BB#0: ## %entry
26 ; CHECK-NEXT:    pshufw $232, (%rdi), %mm0
27 ; CHECK-NEXT:    movd %mm0, %eax
28 ; CHECK-NEXT:    emms
29 ; CHECK-NEXT:    retq
30 entry:
31   %0 = load i32* %ptr, align 4
32   %1 = insertelement <2 x i32> undef, i32 %0, i32 0
33   %2 = insertelement <2 x i32> %1, i32 0, i32 1
34   %3 = bitcast <2 x i32> %2 to x86_mmx
35   %4 = bitcast x86_mmx %3 to i64
36   %5 = bitcast i64 %4 to <4 x i16>
37   %6 = bitcast <4 x i16> %5 to x86_mmx
38   %7 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %6, i8 -24)
39   %8 = bitcast x86_mmx %7 to <4 x i16>
40   %9 = bitcast <4 x i16> %8 to <1 x i64>
41   %10 = extractelement <1 x i64> %9, i32 0
42   %11 = bitcast i64 %10 to <2 x i32>
43   %12 = extractelement <2 x i32> %11, i32 0
44   tail call void @llvm.x86.mmx.emms()
45   ret i32 %12
46 }
47
48 define i32 @test2(i32* nocapture readonly %ptr) {
49 ; CHECK-LABEL: test2:
50 ; CHECK:       ## BB#0: ## %entry
51 ; CHECK-NEXT:    pshufw $232, (%rdi), %mm0
52 ; CHECK-NEXT:    movd %mm0, %eax
53 ; CHECK-NEXT:    emms
54 ; CHECK-NEXT:    retq
55 entry:
56   %0 = bitcast i32* %ptr to x86_mmx*
57   %1 = load x86_mmx* %0, align 8
58   %2 = tail call x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx %1, i8 -24)
59   %3 = bitcast x86_mmx %2 to <4 x i16>
60   %4 = bitcast <4 x i16> %3 to <1 x i64>
61   %5 = extractelement <1 x i64> %4, i32 0
62   %6 = bitcast i64 %5 to <2 x i32>
63   %7 = extractelement <2 x i32> %6, i32 0
64   tail call void @llvm.x86.mmx.emms()
65   ret i32 %7
66 }
67
68 declare x86_mmx @llvm.x86.sse.pshuf.w(x86_mmx, i8)
69 declare void @llvm.x86.mmx.emms()