1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3
foo(int n)4 int foo (int n)
5 {
6 while (n >= 45)
7 n -= 45;
8
9 return n;
10 }
11
bar(int n)12 int bar (int n)
13 {
14 while (n >= 64)
15 n -= 64;
16
17 return n;
18 }
19
bla(int n)20 int bla (int n)
21 {
22 int i = 0;
23
24 while (n >= 45)
25 {
26 i++;
27 n -= 45;
28 }
29
30 return i;
31 }
32
baz(int n)33 int baz (int n)
34 {
35 int i = 0;
36
37 while (n >= 64)
38 {
39 i++;
40 n -= 64;
41 }
42
43 return i;
44 }
45
46 /* The loops computing division/modulo by 64 should be eliminated */
47 /* { dg-final { scan-tree-dump-times "if" 6 "optimized" } } */
48
49 /* There should be no division/modulo in the final dump (division and modulo
50 by 64 are done using bit operations). */
51 /* { dg-final { scan-tree-dump-times " / " 0 "optimized" } } */
52 /* { dg-final { scan-tree-dump-times " % " 0 "optimized" } } */
53
54