1 /* { dg-additional-options "-ffast-math -fdump-tree-optimized" } */
2 
3 #include "tree-vect.h"
4 
5 #define N 4
6 
7 float a[N];
8 
9 float __attribute__ ((noipa))
f1(void)10 f1 (void)
11 {
12   float b[N] = { 1, 0, 0, 0 }, res = 0;
13   for (int i = 0; i < N; ++i)
14     res += a[i] * b[i];
15   return res;
16 }
17 
18 float __attribute__ ((noipa))
f2(void)19 f2 (void)
20 {
21   float b[N] = { 0, 1, 0, 0 }, res = 0;
22   for (int i = 0; i < N; ++i)
23     res += a[i] * b[i];
24   return res;
25 }
26 
27 float __attribute__ ((noipa))
f3(void)28 f3 (void)
29 {
30   float b[N] = { 0, 0, 0, 1 }, res = 0;
31   for (int i = 0; i < N; ++i)
32     res += a[i] * b[i];
33   return res;
34 }
35 
36 int
main()37 main ()
38 {
39   check_vect ();
40 
41   for (int i = 0; i < N; ++i)
42     a[i] = 0xe0 + i;
43 
44   if (f1 () != a[0]
45       || f2 () != a[1]
46       || f3 () != a[N - 1])
47     __builtin_abort ();
48 
49   return 0;
50 }
51 
52 /* ??? We need more constant folding for this to work with fully-masked
53    loops.  */
54 /* { dg-final { scan-tree-dump-not {REDUC_PLUS} "optimized" { xfail aarch64_sve } } } */
55