1/* PR target/29776 */
2/* PR tree-optimization/61725 */
3/* { dg-do compile } */
4/* { dg-options "-O2 -fdump-tree-vrp1" } */
5/* { dg-final { scan-tree-dump-not "link_error" "vrp1"} } */
6/* { dg-final { cleanup-tree-dump "vrp1" } } */
7
8#define A(fn, arg, min, max) \
9  if (__builtin_##fn (arg) < min || __builtin_##fn (arg) > max) \
10    link_error ();
11#define B(fn, min, max) \
12  A (fn, a, min, max) A (fn##l, b, min, max) A (fn##ll, c, min, max)
13#define C(fn, min, sub) \
14  A (fn, a, min, ((int) sizeof (a) * __CHAR_BIT__ - sub)) \
15  A (fn##l, b, min, ((int) sizeof (b) * __CHAR_BIT__ - sub)) \
16  A (fn##ll, c, min, ((int) sizeof (c) * __CHAR_BIT__ - sub))
17
18extern void link_error (void);
19
20unsigned int d;
21unsigned long e;
22unsigned long long f;
23
24void
25foo (int a, long b, long long c)
26{
27  C (ffs, 0, 0)
28  a &= 63; b &= 63; c &= 63;
29  B (ffs, 0, 6)
30  a++; b++; c++;
31  B (ffs, 1, 7)
32  a -= 2; b -= 2; c -= 2;
33  C (ffs, 0, 0)
34  a -= 63; b -= 63; c -= 63;
35  C (ffs, 1, 0)
36}
37