]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/pr43491.c
Fix profile update in tree_transform_and_unroll_loop
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr43491.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3
4 #define REGISTER register
5
6 #if defined __arm__
7 # define REG1 asm("r4")
8 #elif defined __i386__
9 # define REG1 asm("ebx")
10 #elif defined __mips__
11 # define REG1 asm("s0")
12 #elif defined __x86_64__
13 # define REG1 asm("rbp")
14 #else
15 # undef REGISTER
16 # define REGISTER
17 # define REG1
18 #endif
19
20 REGISTER long data_0 REG1;
21 long data_3;
22
23 long foo(long data, long v)
24 {
25 long i;
26 long t, u;
27
28 if (data)
29 i = data_0 + data_3;
30 else {
31 v = 2;
32 i = 5;
33 }
34 t = data_0 + data_3;
35 u = i;
36 return v * t * u;
37 }
38
39 /* We should not eliminate global register variable when it is the RHS of
40 a single assignment. So the number of loads from data_0 has to match
41 that of the number of adds (we hoist data_0 + data_3 above the
42 if (data) and eliminate the useless copy). */
43
44 /* { dg-final { scan-tree-dump-times "= data_0;" 1 "optimized" { target { arm*-*-* i?86-*-* mips*-*-* x86_64-*-* } } } } */
45 /* { dg-final { scan-tree-dump-times " \\+ " 1 "optimized" { target { ! { arm*-*-* i?86-*-* mips*-*-* x86_64-*-* } } } } } */