aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/powerpc/pr48258-1.c
blob: 3ccbf7693d9dac8d2ae1de38d77cbe723e848f1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* { dg-do compile } */
/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
/* { dg-skip-if "" { powerpc*le-*-* } { "*" } { "" } } */
/* { dg-require-effective-target powerpc_vsx_ok } */
/* { dg-options "-O3 -mcpu=power7 -mabi=altivec -ffast-math -fno-unroll-loops" } */
/* { dg-final { scan-assembler-times "xvaddsp" 3 } } */
/* { dg-final { scan-assembler-times "xvminsp" 3 } } */
/* { dg-final { scan-assembler-times "xvmaxsp" 3 } } */
/* { dg-final { scan-assembler-times "xxsldwi" 6 } } */
/* { dg-final { scan-assembler-times "xscvspdp" 3 } } */
/* { dg-final { scan-assembler-not "stvewx" } } */
/* { dg-final { scan-assembler-not "stvx" } } */
/* { dg-final { scan-assembler-not "stxvd2x" } } */
/* { dg-final { scan-assembler-not "stxvw4x" } } */

#include <stddef.h>

#ifndef SIZE
#define SIZE 1024
#endif

float values[SIZE] __attribute__((__aligned__(32)));

float
vector_sum (void)
{
  size_t i;
  float sum = 0.0f;

  for (i = 0; i < SIZE; i++)
    sum += values[i];

  return sum;
}

float
vector_min (void)
{
  size_t i;
  float min = values[0];

  for (i = 0; i < SIZE; i++)
    min = __builtin_fminf (min, values[i]);

  return min;
}

float
vector_max (void)
{
  size_t i;
  float max = values[0];

  for (i = 0; i < SIZE; i++)
    max = __builtin_fmaxf (max, values[i]);

  return max;
}