2013-10-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / var-expand3.c
bloba9d0fe917b83570e16daf1e979fae4fe8368b51b
1 /* { dg-do run { target { powerpc*-*-* && vmx_hw } } }} */
2 /* { dg-options "-O2 -funroll-loops -ffast-math -fvariable-expansion-in-unroller -maltivec -fdump-rtl-loop2_unroll" } */
4 #include "altivec.h"
5 extern void abort (void);
6 extern void exit (int);
8 #define N 256
10 float in1[N] __attribute__ ((__aligned__ (16))) = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57};
11 float in2[N] __attribute__ ((__aligned__ (16))) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
13 float
14 foo (int n)
16 unsigned i;
17 vector float vp1, vp2, vp3, vaccum, vzero, vtmp;
18 float accum = 1.0;
20 vzero = (vector float){0, 0, 0, 0};
22 vaccum = vzero;
24 for (i = 0; i < n; i++)
26 vp1 = vec_ld (i * 16, in1);
27 vp2 = vec_ld (i * 16, in2);
29 vaccum = vec_madd (vp1, vp2, vaccum);
32 vtmp = vec_sld (vaccum, vaccum, 8);
33 vp1 = vec_add (vaccum, vtmp);
34 vtmp = vec_sld (vp1, vp1, 4);
35 vp2 = vec_add (vp1, vtmp);
37 vec_ste (vp2, 0, &accum);
38 if (accum != 1518)
39 return 0;
41 return accum;
44 int
45 main (void)
47 if (!foo (3))
48 abort ();
50 exit (0);
53 /* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" } } */
54 /* { dg-final { cleanup-rtl-dump "loop*" } } */