| 1 |
/* PR target/66112 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
|
| 5 |
unsigned short int |
| 6 |
foo (int a, int b) |
| 7 |
{ |
| 8 |
unsigned short int res; |
| 9 |
a &= 0xffff; |
| 10 |
b &= 0xffff; |
| 11 |
if (__builtin_mul_overflow (a, b, &res)) |
| 12 |
res = 0x123; |
| 13 |
return res; |
| 14 |
} |
| 15 |
|
| 16 |
short int |
| 17 |
bar (int a, int b) |
| 18 |
{ |
| 19 |
short int res; |
| 20 |
a = (short int) a; |
| 21 |
b = (short int) b; |
| 22 |
if (__builtin_mul_overflow (a, b, &res)) |
| 23 |
res = 0x123; |
| 24 |
return res; |
| 25 |
} |
| 26 |
|
| 27 |
/* { dg-final { scan-assembler-times "jn?o\[ \t\]" 2 } } */ |
| 28 |
/* { dg-final { scan-assembler-times "mulw\[ \t\]" 2 } } */ |
| 29 |
/* { dg-final { scan-assembler-times "imulw\[ \t\]" 1 } } */ |