[X86, AVX] replace vinsertf128 intrinsics with generic shuffles
[oota-llvm.git] / test / CodeGen / X86 / avx-intrinsics-x86-upgrade.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -march=x86 -mcpu=corei7-avx | FileCheck %s
2
3 ; We don't check any vinsertf128 variant with immediate 0 because that's just a blend. 
4
5 define <4 x double> @test_x86_avx_vinsertf128_pd_256_1(<4 x double> %a0, <2 x double> %a1) {
6   ; CHECK-LABEL: test_x86_avx_vinsertf128_pd_256_1: 
7   ; CHECK:       vinsertf128 $1, %xmm1, %ymm0, %ymm0
8   %res = call <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double> %a0, <2 x double> %a1, i8 1)
9   ret <4 x double> %res
10 }
11 declare <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double>, <2 x double>, i8) nounwind readnone
12
13 define <8 x float> @test_x86_avx_vinsertf128_ps_256_1(<8 x float> %a0, <4 x float> %a1) {
14   ; CHECK-LABEL: test_x86_avx_vinsertf128_ps_256_1: 
15   ; CHECK:       vinsertf128 $1, %xmm1, %ymm0, %ymm0
16   %res = call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> %a0, <4 x float> %a1, i8 1)
17   ret <8 x float> %res
18 }
19 declare <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float>, <4 x float>, i8) nounwind readnone
20
21 define <8 x i32> @test_x86_avx_vinsertf128_si_256_1(<8 x i32> %a0, <4 x i32> %a1) {
22   ; CHECK-LABEL: test_x86_avx_vinsertf128_si_256_1: 
23   ; CHECK:       vinsertf128 $1, %xmm1, %ymm0, %ymm0
24   %res = call <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32> %a0, <4 x i32> %a1, i8 1)
25   ret <8 x i32> %res
26 }
27
28 ; Verify that high bits of the immediate are masked off. This should be the equivalent
29 ; of a vinsertf128 $0 which should be optimized into a blend, so just check that it's
30 ; not a vinsertf128 $1.
31 define <8 x i32> @test_x86_avx_vinsertf128_si_256_2(<8 x i32> %a0, <4 x i32> %a1) {
32   ; CHECK-LABEL: test_x86_avx_vinsertf128_si_256_2: 
33   ; CHECK-NOT:   vinsertf128 $1, %xmm1, %ymm0, %ymm0
34   %res = call <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32> %a0, <4 x i32> %a1, i8 2)
35   ret <8 x i32> %res
36 }
37 declare <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32>, <4 x i32>, i8) nounwind readnone
38
39 define <4 x double> @test_x86_avx_blend_pd_256(<4 x double> %a0, <4 x double> %a1) {
40   ; CHECK: vblendpd
41   %res = call <4 x double> @llvm.x86.avx.blend.pd.256(<4 x double> %a0, <4 x double> %a1, i32 7) ; <<4 x double>> [#uses=1]
42   ret <4 x double> %res
43 }
44 declare <4 x double> @llvm.x86.avx.blend.pd.256(<4 x double>, <4 x double>, i32) nounwind readnone
45
46
47 define <8 x float> @test_x86_avx_blend_ps_256(<8 x float> %a0, <8 x float> %a1) {
48   ; CHECK: vblendps
49   %res = call <8 x float> @llvm.x86.avx.blend.ps.256(<8 x float> %a0, <8 x float> %a1, i32 7) ; <<8 x float>> [#uses=1]
50   ret <8 x float> %res
51 }
52 declare <8 x float> @llvm.x86.avx.blend.ps.256(<8 x float>, <8 x float>, i32) nounwind readnone
53
54
55 define <8 x float> @test_x86_avx_dp_ps_256(<8 x float> %a0, <8 x float> %a1) {
56   ; CHECK: vdpps
57   %res = call <8 x float> @llvm.x86.avx.dp.ps.256(<8 x float> %a0, <8 x float> %a1, i32 7) ; <<8 x float>> [#uses=1]
58   ret <8 x float> %res
59 }
60 declare <8 x float> @llvm.x86.avx.dp.ps.256(<8 x float>, <8 x float>, i32) nounwind readnone
61
62
63 define <2 x i64> @test_x86_sse2_psll_dq(<2 x i64> %a0) {
64   ; CHECK: vpslldq {{.*#+}} xmm0 = zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
65   %res = call <2 x i64> @llvm.x86.sse2.psll.dq(<2 x i64> %a0, i32 8) ; <<2 x i64>> [#uses=1]
66   ret <2 x i64> %res
67 }
68 declare <2 x i64> @llvm.x86.sse2.psll.dq(<2 x i64>, i32) nounwind readnone
69
70
71 define <2 x i64> @test_x86_sse2_psrl_dq(<2 x i64> %a0) {
72   ; CHECK: vpsrldq {{.*#+}} xmm0 = xmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero
73   %res = call <2 x i64> @llvm.x86.sse2.psrl.dq(<2 x i64> %a0, i32 8) ; <<2 x i64>> [#uses=1]
74   ret <2 x i64> %res
75 }
76 declare <2 x i64> @llvm.x86.sse2.psrl.dq(<2 x i64>, i32) nounwind readnone
77
78
79 define <2 x double> @test_x86_sse41_blendpd(<2 x double> %a0, <2 x double> %a1) {
80   ; CHECK: vblendpd
81   %res = call <2 x double> @llvm.x86.sse41.blendpd(<2 x double> %a0, <2 x double> %a1, i8 2) ; <<2 x double>> [#uses=1]
82   ret <2 x double> %res
83 }
84 declare <2 x double> @llvm.x86.sse41.blendpd(<2 x double>, <2 x double>, i8) nounwind readnone
85
86
87 define <4 x float> @test_x86_sse41_blendps(<4 x float> %a0, <4 x float> %a1) {
88   ; CHECK: vblendps
89   %res = call <4 x float> @llvm.x86.sse41.blendps(<4 x float> %a0, <4 x float> %a1, i8 7) ; <<4 x float>> [#uses=1]
90   ret <4 x float> %res
91 }
92 declare <4 x float> @llvm.x86.sse41.blendps(<4 x float>, <4 x float>, i8) nounwind readnone
93
94
95 define <8 x i16> @test_x86_sse41_pblendw(<8 x i16> %a0, <8 x i16> %a1) {
96   ; CHECK: vpblendw
97   %res = call <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16> %a0, <8 x i16> %a1, i8 7) ; <<8 x i16>> [#uses=1]
98   ret <8 x i16> %res
99 }
100 declare <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16>, <8 x i16>, i8) nounwind readnone