summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr66112-2.c
blob: 7fc18811638adadb447d3f5e1b9a520b63a2ec21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* PR target/66112 */
/* { dg-do compile } */
/* { dg-options "-O2" } */

unsigned short int
foo (int a, int b)
{
  unsigned short int res;
  a &= 0xffff;
  b &= 0xffff;
  if (__builtin_mul_overflow (a, b, &res))
    res = 0x123;
  return res;
}

short int
bar (int a, int b)
{
  short int res;
  a = (short int) a;
  b = (short int) b;
  if (__builtin_mul_overflow (a, b, &res))
    res = 0x123;
  return res;
}

/* { dg-final { scan-assembler-times "jn?o\[ \t\]" 2 } } */
/* { dg-final { scan-assembler-times "mulw\[ \t\]" 2 } } */
/* { dg-final { scan-assembler-times "imulw\[ \t\]" 1 } } */