[Hexagon] Adding add/sub with saturation. Removing unused def. Cleaning up shift...
[oota-llvm.git] / test / CodeGen / X86 / vec_loadsingles.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx,-slow-unaligned-mem-32 | FileCheck %s --check-prefix=ALL --check-prefix=FAST32
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx,+slow-unaligned-mem-32 | FileCheck %s --check-prefix=ALL --check-prefix=SLOW32
3
4 define <4 x float> @merge_2_floats(float* nocapture %p) nounwind readonly {
5   %tmp1 = load float* %p
6   %vecins = insertelement <4 x float> undef, float %tmp1, i32 0
7   %add.ptr = getelementptr float* %p, i32 1
8   %tmp5 = load float* %add.ptr
9   %vecins7 = insertelement <4 x float> %vecins, float %tmp5, i32 1
10   ret <4 x float> %vecins7
11
12 ; ALL-LABEL: merge_2_floats
13 ; ALL: vmovq
14 ; ALL-NEXT: retq
15 }
16
17 define <4 x float> @merge_4_floats(float* %ptr) {
18   %a = load float* %ptr, align 8
19   %vec = insertelement <4 x float> undef, float %a, i32 0
20   %idx1 = getelementptr inbounds float* %ptr, i64 1
21   %b = load float* %idx1, align 8
22   %vec2 = insertelement <4 x float> %vec, float %b, i32 1
23   %idx3 = getelementptr inbounds float* %ptr, i64 2
24   %c = load float* %idx3, align 8
25   %vec4 = insertelement <4 x float> %vec2, float %c, i32 2
26   %idx5 = getelementptr inbounds float* %ptr, i64 3
27   %d = load float* %idx5, align 8
28   %vec6 = insertelement <4 x float> %vec4, float %d, i32 3
29   ret <4 x float> %vec6
30
31 ; ALL-LABEL: merge_4_floats
32 ; ALL: vmovups
33 ; ALL-NEXT: retq
34 }
35
36 ; PR21710 ( http://llvm.org/bugs/show_bug.cgi?id=21710 ) 
37 ; Make sure that 32-byte vectors are handled efficiently.
38 ; If the target has slow 32-byte accesses, we should still generate
39 ; 16-byte loads.
40
41 define <8 x float> @merge_8_floats(float* %ptr) {
42   %a = load float* %ptr, align 4
43   %vec = insertelement <8 x float> undef, float %a, i32 0
44   %idx1 = getelementptr inbounds float* %ptr, i64 1
45   %b = load float* %idx1, align 4
46   %vec2 = insertelement <8 x float> %vec, float %b, i32 1
47   %idx3 = getelementptr inbounds float* %ptr, i64 2
48   %c = load float* %idx3, align 4
49   %vec4 = insertelement <8 x float> %vec2, float %c, i32 2
50   %idx5 = getelementptr inbounds float* %ptr, i64 3
51   %d = load float* %idx5, align 4
52   %vec6 = insertelement <8 x float> %vec4, float %d, i32 3
53   %idx7 = getelementptr inbounds float* %ptr, i64 4
54   %e = load float* %idx7, align 4
55   %vec8 = insertelement <8 x float> %vec6, float %e, i32 4
56   %idx9 = getelementptr inbounds float* %ptr, i64 5
57   %f = load float* %idx9, align 4
58   %vec10 = insertelement <8 x float> %vec8, float %f, i32 5
59   %idx11 = getelementptr inbounds float* %ptr, i64 6
60   %g = load float* %idx11, align 4
61   %vec12 = insertelement <8 x float> %vec10, float %g, i32 6
62   %idx13 = getelementptr inbounds float* %ptr, i64 7
63   %h = load float* %idx13, align 4
64   %vec14 = insertelement <8 x float> %vec12, float %h, i32 7
65   ret <8 x float> %vec14
66
67 ; ALL-LABEL: merge_8_floats
68
69 ; FAST32: vmovups
70 ; FAST32-NEXT: retq
71
72 ; SLOW32: vmovups
73 ; SLOW32: vinsertf128
74 ; SLOW32-NEXT: retq
75 }
76
77 define <4 x double> @merge_4_doubles(double* %ptr) {
78   %a = load double* %ptr, align 8
79   %vec = insertelement <4 x double> undef, double %a, i32 0
80   %idx1 = getelementptr inbounds double* %ptr, i64 1
81   %b = load double* %idx1, align 8
82   %vec2 = insertelement <4 x double> %vec, double %b, i32 1
83   %idx3 = getelementptr inbounds double* %ptr, i64 2
84   %c = load double* %idx3, align 8
85   %vec4 = insertelement <4 x double> %vec2, double %c, i32 2
86   %idx5 = getelementptr inbounds double* %ptr, i64 3
87   %d = load double* %idx5, align 8
88   %vec6 = insertelement <4 x double> %vec4, double %d, i32 3
89   ret <4 x double> %vec6
90
91 ; ALL-LABEL: merge_4_doubles
92 ; FAST32: vmovups
93 ; FAST32-NEXT: retq
94
95 ; SLOW32: vmovups
96 ; SLOW32: vinsertf128
97 ; SLOW32-NEXT: retq
98 }
99