arm: fix typo in dg-require-effective-target [PR118089]
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr107195-3.c
blobeba4218b3c91decdd79d98ef2829b3bea75cab7c
1 /* Inspired by 'libgomp.oacc-c-c++-common/nvptx-sese-1.c'. */
3 /* { dg-additional-options -O1 } */
4 /* { dg-additional-options -fdump-tree-dom3-raw } */
7 extern int
8 __attribute__((const))
9 foo1 (int);
11 int f1 (int r)
13 if (foo1 (r)) /* If this first 'if' holds... */
14 r *= 2; /* ..., 'r' now has a zero-value lower-most bit... */
16 if (r & 1) /* ..., so this second 'if' can never hold... */
17 { /* ..., so this is unreachable. */
18 /* In constrast, if the first 'if' does not hold ('foo1 (r) == 0'), the
19 second 'if' may hold, but we know ('foo1' being 'const') that
20 'foo1 (r) == 0', so don't have to re-evaluate it here: */
21 r += foo1 (r);
24 return r;
26 /* Thus, if optimizing, we only ever expect one call of 'foo1'.
27 { dg-final { scan-tree-dump-times {gimple_call <foo1,} 1 dom3 } } */
30 extern int
31 __attribute__((const))
32 foo2 (int);
34 int f2 (int r)
36 if (foo2 (r))
37 r *= 8;
39 if (r & 7)
40 r += foo2 (r);
42 return r;
44 /* { dg-final { scan-tree-dump-times {gimple_call <foo2,} 1 dom3 } } */
47 extern int
48 __attribute__((const))
49 foo3 (int);
51 int f3 (int r)
53 if (foo3 (r))
54 r <<= 4;
56 if ((r & 64) && ((r & 8) || (r & 4) || (r & 2) || (r & 1)))
57 r += foo3 (r);
59 return r;
61 /* { dg-final { scan-tree-dump-times {gimple_call <foo3,} 1 dom3 } } */
64 extern int
65 __attribute__((const))
66 foo4 (int);
68 int f4 (int r)
70 if (foo4 (r))
71 r *= 8;
73 if ((r >> 1) & 2)
74 r += foo4 (r);
76 return r;
78 /* { dg-final { scan-tree-dump-times {gimple_call <foo4,} 1 dom3 } } */
81 extern int
82 __attribute__((const))
83 foo5 (int);
85 int f5 (int r) /* Works for both 'signed' and 'unsigned'. */
87 if (foo5 (r))
88 r *= 2;
90 if ((r % 2) != 0)
91 r += foo5 (r);
93 return r;
95 /* { dg-final { scan-tree-dump-times {gimple_call <foo5,} 1 dom3 } } */
98 extern int
99 __attribute__((const))
100 foo6 (int);
102 int f6 (unsigned int r) /* 'unsigned' is important here. */
104 if (foo6 (r))
105 r *= 2;
107 if ((r % 2) == 1)
108 r += foo6 (r);
110 return r;
112 /* { dg-final { scan-tree-dump-times {gimple_call <foo6,} 1 dom3 } } */