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
|
/* { dg-do compile } */
/* { dg-options "-O2 -mdejagnu-cpu=power9 -mvsx -ffast-math" } */
/* { dg-require-effective-target powerpc_vsx } */
/* { dg-final { scan-assembler-times {\mxsmaxcdp\M} 2 } } */
/* { dg-final { scan-assembler-times {\mxsmincdp\M} 2 } } */
/* This test verifies that float or double vec_min/max can be converted
to scalar comparison when fast-math is set. */
#include <altivec.h>
#ifdef _BIG_ENDIAN
const int PREF_D = 0;
#else
const int PREF_D = 1;
#endif
double vmaxd (double a, double b)
{
vector double va = vec_promote (a, PREF_D);
vector double vb = vec_promote (b, PREF_D);
return vec_extract (vec_max (va, vb), PREF_D);
}
double vmind (double a, double b)
{
vector double va = vec_promote (a, PREF_D);
vector double vb = vec_promote (b, PREF_D);
return vec_extract (vec_min (va, vb), PREF_D);
}
#ifdef _BIG_ENDIAN
const int PREF_F = 0;
#else
const int PREF_F = 3;
#endif
float vmaxf (float a, float b)
{
vector float va = vec_promote (a, PREF_F);
vector float vb = vec_promote (b, PREF_F);
return vec_extract (vec_max (va, vb), PREF_F);
}
float vminf (float a, float b)
{
vector float va = vec_promote (a, PREF_F);
vector float vb = vec_promote (b, PREF_F);
return vec_extract (vec_min (va, vb), PREF_F);
}
|