(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr67089-6.c
       1  /* PR target/67089 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-O2 -fno-tree-vectorize -ftree-loop-if-convert -fdump-tree-widening_mul" } */
       4  
       5  extern void abort (void);
       6  
       7  int cnt;
       8  unsigned int a[16], b[16], c[16], d;
       9  void foo (int x);
      10  
      11  __attribute__((noinline, noclone)) void
      12  f0 (unsigned int x)
      13  {
      14    for (int i = 0; i < 16; i++)
      15      {
      16        unsigned int r = x - a[i];
      17        b[i] = r;
      18        c[i] = r > x ? 7 : x;
      19      }
      20  }
      21  
      22  #define T(n, type, op, cond) \
      23  __attribute__((noinline, noclone))	\
      24  type					\
      25  f##n (type x, type y)			\
      26  {					\
      27    type r = op;				\
      28    cond;					\
      29    return r;				\
      30  }
      31  
      32  T (1, unsigned int, x - y, if (r > x) foo (0))
      33  T (2, unsigned long, x - y, if (r <= x) foo (0))
      34  T (3, unsigned short, x - y, if (x < r) foo (r))
      35  T (4, unsigned long long, x - y, if (x >= r) foo (0))
      36  T (5, unsigned int, x - y, if (d || r > x) foo (0))
      37  T (6, unsigned long, x - y, if (d || r <= x) foo (0))
      38  T (7, unsigned char, x - y, if (d || x < r) foo (0))
      39  T (8, unsigned long long, x - y, if (d || x >= r) foo (0))
      40  T (9, unsigned int, x + y, if (r >= x) foo (0))
      41  T (10, unsigned long, x + y, if (r < x) foo (0))
      42  T (11, unsigned short, x + y, if (x <= r) foo (r))
      43  T (12, unsigned long long, x + y, if (d || x > r) foo (0))
      44  T (13, unsigned int, x + y, if (d || r >= x) foo (0))
      45  T (14, unsigned long, x + y, if (d || r < x) foo (0))
      46  T (15, unsigned short, x + y, if (d || x <= r) foo (0))
      47  T (16, unsigned long long, x + y, if (d || x > r) foo (0))
      48  T (17, unsigned int, x + y, if (r >= y) foo (0))
      49  T (18, unsigned long, x + y, if (r < y) foo (0))
      50  T (19, unsigned short, x + y, if (y <= r) foo (r))
      51  T (20, unsigned long long, x + y, if (d || y > r) foo (0))
      52  T (21, unsigned int, x + y, if (d || r >= y) foo (0))
      53  T (22, unsigned long, x + y, if (d || r < y) foo (0))
      54  T (23, unsigned short, x + y, if (d || y <= r) foo (0))
      55  T (24, unsigned long long, x + y, if (d || y > r) foo (0))
      56  T (25, unsigned short, 2U - x, if (r > 2U) foo (0))
      57  T (26, unsigned char, 2U - x, if (r <= 2U) foo (0))
      58  
      59  /* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 16 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */
      60  /* { dg-final { scan-tree-dump-times "SUB_OVERFLOW" 11 "widening_mul" { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
      61  /* { dg-final { scan-tree-dump-times "SUB_OVERFLOW" 9 "widening_mul" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */