Debian Codegraph @

gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-ipa-icf-optimized" } */
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 int gcd(int x, int y) __attribute__ ((pure));
8
9 __attribute__ ((noinline))
10 int gcd(int x, int y)
11 {
12 int swap;
13
14 if(x <= 0 || y <= 0)
15 return 0;
16
17 if(x < y)
18 {
19 swap = x;
20 x = y;
21 y = swap;
22 }
23
24 while(x != y)
25 {
26 x = x - y;
27
28 if(y > x)
29 {
30 swap = x;
31 x = y;
32 y = swap;
33 }
34 }
35
36 return x;
37 }
38
39 int nsd(int x, int y) __attribute__ ((pure));
40
41 __attribute__ ((noinline))
42 int nsd(int x, int y)
43 {
44 int swap;
45
46 if(x <= 0 || y <= 0)
47 return 0;
48
49 if(x < y)
50 {
51 swap = x;
52 x = y;
53 y = swap;
54 }
55
56 while(x != y)
57 {
58 x = x - y;
59
60 if(y > x)
61 {
62 swap = x;
63 x = y;
64 y = swap;
65 }
66 }
67
68 return x;
69 }
70
71 int main(int argc, char **argv)
72 {
73 return 0;
74 }
75
76 /* { dg-final { scan-ipa-dump "Semantic equality hit:gcd/\[0-9+\]+->nsd/\[0-9+\]+" "icf" } } */
77 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */