| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-additional-options "-O3 -std=c99 -save-temps" } */ |
| 3 |
/* { dg-final { check-function-bodies "**" "" "" { target { le } } } } */ |
| 4 |
|
| 5 |
#pragma GCC target "+nosve" |
| 6 |
|
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
typedef int v4si __attribute__ ((vector_size (16))); |
| 10 |
|
| 11 |
|
| 12 |
/* |
| 13 |
**foo1: |
| 14 |
** cmgt v0.4s, v1.4s, v0.4s |
| 15 |
** bsl v0.16b, v2.16b, v3.16b |
| 16 |
** ret |
| 17 |
*/ |
| 18 |
v4si foo1 (v4si a, v4si b, v4si c, v4si d) { |
| 19 |
return ((a < b) & c) | ((a >= b) & d); |
| 20 |
} |
| 21 |
|
| 22 |
/* |
| 23 |
**foo2: |
| 24 |
** cmgt v0.4s, v1.4s, v0.4s |
| 25 |
** bsl v0.16b, v3.16b, v2.16b |
| 26 |
** ret |
| 27 |
*/ |
| 28 |
v4si foo2 (v4si a, v4si b, v4si c, v4si d) { |
| 29 |
return (~(a < b) & c) | (~(a >= b) & d); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
/* The bsl could be bit or bif depending on register |
| 34 |
allocator inside the loop. */ |
| 35 |
/** |
| 36 |
**bar1: |
| 37 |
**... |
| 38 |
** cmge v[0-9]+.4s, v[0-9]+.4s, v[0-9]+.4s |
| 39 |
** (bsl|bit|bif) v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b |
| 40 |
** and v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b |
| 41 |
**... |
| 42 |
*/ |
| 43 |
void bar1 (int * restrict a, int * restrict b, int * restrict c, |
| 44 |
int * restrict d, int * restrict res, int n) |
| 45 |
{ |
| 46 |
for (int i = 0; i < (n & -4); i++) |
| 47 |
res[i] = ((a[i] < b[i]) & c[i]) | ((a[i] >= b[i]) & d[i]); |
| 48 |
} |
| 49 |
|
| 50 |
/* The bsl could be bit or bif depending on register |
| 51 |
allocator inside the loop. */ |
| 52 |
/** |
| 53 |
**bar2: |
| 54 |
**... |
| 55 |
** cmge v[0-9]+.4s, v[0-9]+.4s, v[0-9]+.4s |
| 56 |
** (bsl|bit|bif) v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b |
| 57 |
**... |
| 58 |
*/ |
| 59 |
void bar2 (int * restrict a, int * restrict b, int * restrict c, |
| 60 |
int * restrict d, int * restrict res, int n) |
| 61 |
{ |
| 62 |
for (int i = 0; i < (n & -4); i++) |
| 63 |
res[i] = (-(a[i] < b[i]) & c[i]) | (-(a[i] >= b[i]) & d[i]); |
| 64 |
} |
| 65 |
|
| 66 |
extern void abort (); |
| 67 |
|
| 68 |
int main () |
| 69 |
{ |
| 70 |
|
| 71 |
v4si a = { -3, -3, -3, -3 }; |
| 72 |
v4si b = { 3, 3, 3, 3 }; |
| 73 |
v4si c = { 5, 5, 5, 5 }; |
| 74 |
v4si d = { 8, 8, 8, 8 }; |
| 75 |
|
| 76 |
v4si res1 = foo1 (a, b, c, d); |
| 77 |
if (memcmp (&res1, &c, 16UL) != 0) |
| 78 |
abort (); |
| 79 |
|
| 80 |
v4si res2 = foo2 (a, b, c, d); |
| 81 |
if (memcmp (&res2, &d, 16UL) != 0) |
| 82 |
abort (); |
| 83 |
|
| 84 |
int ar[4] = { -3, -3, -3, -3 }; |
| 85 |
int br[4] = { 3, 3, 3, 3 }; |
| 86 |
int cr[4] = { 5, 5, 5, 5 }; |
| 87 |
int dr[4] = { 8, 8, 8, 8 }; |
| 88 |
|
| 89 |
int exp1[4] = { 1, 1, 1, 1 }; |
| 90 |
int res3[4]; |
| 91 |
bar1 ((int*)&ar, (int*)&br, (int*)&cr, (int*)&dr, (int*)&res3, 4); |
| 92 |
if (memcmp (&res3, &exp1, 16UL) != 0) |
| 93 |
abort (); |
| 94 |
|
| 95 |
int res4[4]; |
| 96 |
bar2 ((int*)&ar, (int*)&br, (int*)&cr, (int*)&dr, (int*)&res4, 4); |
| 97 |
if (memcmp (&res4, &cr, 16UL) != 0) |
| 98 |
abort (); |
| 99 |
|
| 100 |
return 0; |
| 101 |
} |