1 /* { dg-require-effective-target vect_float } */
2 /* { dg-add-options double_vectors } */
3
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #define N 256
8
9 __attribute__ ((noinline))
bar(float * pa,float * pb,float * pc)10 void bar (float *pa, float *pb, float *pc)
11 {
12 int i;
13
14 /* check results: */
15 for (i = 0; i < N; i++)
16 {
17 if (pa[i] != (pb[i] * pc[i]))
18 abort ();
19 }
20
21 return;
22 }
23
24 /* Unaligned write access, aligned read accesses.
25 Since we are handling an unaligned store by peeling the loop,
26 the loads will become unaligned.
27 The loop bound is known and divisible by the vectorization factor.
28 No aliasing problems. */
29
30 __attribute__ ((noinline)) int
main1(float * __restrict__ pa,float * pb,float * pc)31 main1 (float * __restrict__ pa, float *pb, float *pc)
32 {
33 float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
34 float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
35 int i;
36
37 /* We also vectorize this loop. */
38 for (i = 0; i < N; i++)
39 {
40 b[i] = pb[i];
41 c[i] = pc[i];
42 }
43
44 for (i = 0; i < N; i++)
45 {
46 pa[i] = b[i] * c[i];
47 }
48
49 return 0;
50 }
51
main(void)52 int main (void)
53 {
54 int i;
55 float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
56 float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
57 float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
58
59 check_vect ();
60
61 main1 (a,b,c);
62 bar (a,b,c);
63 return 0;
64 }
65
66 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
67 /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */
68 /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { { ! vector_alignment_reachable } && { ! vect_element_align } } } } } */
69 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { xfail { vect_no_align || { { ! vector_alignment_reachable } || vect_element_align } } } } } */
70 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target vect_element_align xfail { ! { vect_unaligned_possible && vect_align_stack_vars } } } } } */
71 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_no_align || { { ! vector_alignment_reachable } || vect_element_align } } } } } */
72