| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target vmx_hw } */ |
| 3 |
/* { dg-options "-O2 -maltivec" } */ |
| 4 |
|
| 5 |
#include <altivec.h> |
| 6 |
|
| 7 |
/* The initial implementation of vec_sel used an IF_THEN_ELSE rtx. |
| 8 |
This did NOT match what the vsel instruction does. vsel is a |
| 9 |
bit-wise operation. Using IF_THEN_ELSE made the + operation to be |
| 10 |
simplified away in combine. A plus operation affects other bits in |
| 11 |
the same element. Hence per-element simplifications are wrong for |
| 12 |
vsel. */ |
| 13 |
vector unsigned char __attribute__((noinline)) |
| 14 |
foo (vector unsigned char a, vector unsigned char b, vector unsigned char c) |
| 15 |
{ |
| 16 |
return vec_sel (a + b, c, a); |
| 17 |
} |
| 18 |
|
| 19 |
vector unsigned char __attribute__((noinline)) |
| 20 |
foor (vector unsigned char a, vector unsigned char b, vector unsigned char c) |
| 21 |
{ |
| 22 |
return vec_sel (c, a + b, ~a); |
| 23 |
} |
| 24 |
|
| 25 |
vector unsigned char __attribute__((noinline)) |
| 26 |
bar (vector unsigned char a, vector unsigned char b, vector unsigned char c) |
| 27 |
{ |
| 28 |
return vec_sel (a | b, c, a); |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
main () |
| 33 |
{ |
| 34 |
vector unsigned char v = (vector unsigned char){ 1 }; |
| 35 |
|
| 36 |
if (foo (v, v, v)[0] != 3) |
| 37 |
__builtin_abort (); |
| 38 |
|
| 39 |
if (bar (v, v, v)[0] != 1) |
| 40 |
__builtin_abort (); |
| 41 |
|
| 42 |
if (foor (v, v, v)[0] != 3) |
| 43 |
__builtin_abort (); |
| 44 |
|
| 45 |
return 0; |
| 46 |
} |
| 47 |
|