PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / ipa-icf-12.c
blob8e4aa56b032f217b46e4db060c65d425fee8234e
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-ipa-icf" } */
4 #include <stdlib.h>
5 #include <stdio.h>
7 int gcd(int x, int y) __attribute__ ((pure));
9 __attribute__ ((noinline))
10 int gcd(int x, int y)
12 int swap;
14 if(x <= 0 || y <= 0)
15 return 0;
17 if(x < y)
19 swap = x;
20 x = y;
21 y = swap;
24 while(x != y)
26 x = x - y;
28 if(y > x)
30 swap = x;
31 x = y;
32 y = swap;
36 return x;
39 int nsd(int x, int y) __attribute__ ((pure));
41 __attribute__ ((noinline))
42 int nsd(int x, int y)
44 int swap;
46 if(x <= 0 || y <= 0)
47 return 0;
49 if(x < y)
51 swap = x;
52 x = y;
53 y = swap;
56 while(x != y)
58 x = x - y;
60 if(y > x)
62 swap = x;
63 x = y;
64 y = swap;
68 return x;
71 int main(int argc, char **argv)
73 return 0;
76 /* { dg-final { scan-ipa-dump "Semantic equality hit:gcd->nsd" "icf" } } */
77 /* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */