| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -msse4" } */ |
| 3 |
/* { dg-require-effective-target sse4 } */ |
| 4 |
|
| 5 |
typedef unsigned short u16; |
| 6 |
typedef unsigned int u32; |
| 7 |
typedef unsigned char u8; |
| 8 |
|
| 9 |
u32 |
| 10 |
__attribute__((__force_align_arg_pointer__)) |
| 11 |
unreach(const u16 * pu16, u16 *dst, u32 dstlen, const u8 *src, u32 srclen) |
| 12 |
{ |
| 13 |
for (u32 i = dstlen; srclen && i; i--, srclen--, src++, dst++) |
| 14 |
{ |
| 15 |
u16 off = pu16[*src]; |
| 16 |
if (off) |
| 17 |
{ |
| 18 |
src++; srclen--; |
| 19 |
*dst = pu16[off + *src]; |
| 20 |
} |
| 21 |
} |
| 22 |
return 56; |
| 23 |
} |
| 24 |
|
| 25 |
u32 |
| 26 |
__attribute__((__force_align_arg_pointer__)) |
| 27 |
__attribute__((noipa)) |
| 28 |
bug(const u16 * pu16, u16 *dst, u32 dstlen, const u8 *src, u32 srclen) |
| 29 |
{ |
| 30 |
if (pu16) |
| 31 |
/* Branch should not execute, but stack realignment |
| 32 |
* reads wrong 'pu16' value from stack. */ |
| 33 |
return unreach(pu16, dst, dstlen, src, srclen); |
| 34 |
|
| 35 |
return (srclen < dstlen) ? srclen : dstlen; |
| 36 |
} |
| 37 |
|
| 38 |
int |
| 39 |
main() |
| 40 |
{ |
| 41 |
if (__builtin_cpu_supports ("sse4.1")) |
| 42 |
{ |
| 43 |
/* Should return 12 */ |
| 44 |
if (bug(0, 0, 12, 0, 34) != 12) |
| 45 |
__builtin_abort (); |
| 46 |
} |
| 47 |
return 0; |
| 48 |
} |