aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/ivcanon-1.c
blob: 430a9514ca52e186368323c2d187fdd4c896d438 (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
30
31
32
33
34
35
36
37
/* { dg-do compile } */ 
/* { dg-options "-O2 -ftree-loop-optimize -fscalar-evolutions -funroll-loops -fdump-tree-optimized" } */

void foo(void)
{
  int n = 16875;

  while (n)
    {
      if (n&1)
	bar (n);
      n >>= 1;
    }
}

static inline int power (long x, unsigned int n)
{
  long y = n % 2 ? x : 1;

  while (n >>= 1)
    {
      x = x * x;
      if (n % 2)
	y = y * x;
    }

  return y;
}

void test(long x)
{
  bar (power (x, 10));
  bar (power (x, 27));
}

/* All loops should be completely unrolled, so there should be no labels.  */
/* { dg-final { scan-tree-dump-times "<L" 0 "optimized"} } */