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