| 1 |
// { dg-do run } |
| 2 |
/* PR tree-optimization/116098 */ |
| 3 |
|
| 4 |
|
| 5 |
static bool truthy(int type, unsigned char data) __attribute__((noipa)); |
| 6 |
/* truthy was being miscompiled for the type==2 case, |
| 7 |
because we would have a VCE from unsigned char to bool |
| 8 |
that went from being conditional in the type==1 case |
| 9 |
to unconditional when `type!=0`. |
| 10 |
The move of the VCE from conditional to unconditional, |
| 11 |
needs to changed into a convert (NOP_EXPR). */ |
| 12 |
|
| 13 |
static bool truthy(void) __attribute__((noipa)); |
| 14 |
static bool |
| 15 |
truthy(int type, unsigned char data) |
| 16 |
{ |
| 17 |
if (type == 0) |
| 18 |
return 0; |
| 19 |
if (type == 1) |
| 20 |
/* Emulate what SRA does, so this can be |
| 21 |
tested without depending on SRA. */ |
| 22 |
return __builtin_bit_cast (bool, data); |
| 23 |
return 1; |
| 24 |
} |
| 25 |
|
| 26 |
int |
| 27 |
main(void) |
| 28 |
{ |
| 29 |
bool b1 = !truthy(2, -1); |
| 30 |
bool b = truthy(1, b1); |
| 31 |
if (b1 != b) __builtin_abort(); |
| 32 |
if (b) __builtin_abort(); |
| 33 |
} |