| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
typedef unsigned long long u64; |
| 5 |
|
| 6 |
#define MAX_SUBTARGET_WORDS 4 |
| 7 |
|
| 8 |
int notequal(const void *a, const void *b) |
| 9 |
{ |
| 10 |
return __builtin_memcmp(a,b,MAX_SUBTARGET_WORDS*sizeof(u64)) != 0; |
| 11 |
} |
| 12 |
typedef struct FeatureBitset { |
| 13 |
u64 Bits[MAX_SUBTARGET_WORDS]; |
| 14 |
}FeatureBitset; |
| 15 |
|
| 16 |
__attribute__((noipa)) |
| 17 |
_Bool is_eq_buggy (const FeatureBitset * lf, const FeatureBitset * rf) { |
| 18 |
u64 Bits_l[MAX_SUBTARGET_WORDS]; |
| 19 |
Bits_l[0] = lf->Bits[0]&1; |
| 20 |
Bits_l[1] = 0; |
| 21 |
Bits_l[2] = 0; |
| 22 |
Bits_l[3] = 0; |
| 23 |
u64 Bits_r[MAX_SUBTARGET_WORDS]; |
| 24 |
Bits_r[0] = rf->Bits[0]&1; |
| 25 |
Bits_r[1] = 0; |
| 26 |
Bits_r[2] = 0; |
| 27 |
Bits_r[3] = 0; |
| 28 |
return !notequal(Bits_l, Bits_r); |
| 29 |
} |
| 30 |
|
| 31 |
__attribute__((noipa)) |
| 32 |
void bug(void) { |
| 33 |
FeatureBitset lf, rf; |
| 34 |
lf.Bits[0] = rf.Bits[0] = 1; |
| 35 |
lf.Bits[1] = rf.Bits[1] = 1; |
| 36 |
lf.Bits[2] = rf.Bits[2] = 1; |
| 37 |
lf.Bits[3] = rf.Bits[3] = 1; |
| 38 |
|
| 39 |
_Bool r = is_eq_buggy (&lf, &rf); |
| 40 |
if (!r) __builtin_trap(); |
| 41 |
} |
| 42 |
|
| 43 |
__attribute__((noipa)) |
| 44 |
int main(void) { |
| 45 |
bug(); |
| 46 |
} |