Debian Codegraph @

gcc/testsuite/g++.dg/pr94920.C

raw
1 /* PR tree-optimization/94920 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wno-psabi -fdump-tree-forwprop1" } */
4
5 typedef int __attribute__((vector_size(4*sizeof(int)))) vint;
6
7 /* Same form as PR. */
8 __attribute__((noipa)) unsigned int foo(int x) {
9 return (x >= 0 ? x : 0) + (x <= 0 ? -x : 0);
10 }
11
12 /* Test for forward propogation. */
13 __attribute__((noipa)) unsigned int corge(int x) {
14 int w = (x >= 0 ? x : 0);
15 int y = -x;
16 int z = (y >= 0 ? y : 0);
17 return w + z;
18 }
19
20 /* Vector case. */
21 __attribute__((noipa)) vint thud(vint x) {
22 vint t = (x >= 0 ? x : 0) ;
23 vint xx = -x;
24 vint t1 = (xx >= 0 ? xx : 0);
25 return t + t1;
26 }
27
28 /* Signed function. */
29 __attribute__((noipa)) int bar(int x) {
30 return (x >= 0 ? x : 0) + (x <= 0 ? -x : 0);
31 }
32
33 /* Commutative property. */
34 __attribute__((noipa)) unsigned int baz(int x) {
35 return (x <= 0 ? -x : 0) + (x >= 0 ? x : 0);
36 }
37
38 /* Flipped order for max expressions. */
39 __attribute__((noipa)) unsigned int quux(int x) {
40 return (0 <= x ? x : 0) + (0 >= x ? -x : 0);
41 }
42
43 /* Not zero so should not optimize. */
44 __attribute__((noipa)) unsigned int waldo(int x) {
45 return (x >= 4 ? x : 4) + (x <= 4 ? -x : 4);
46 }
47
48 /* Not zero so should not optimize. */
49 __attribute__((noipa)) unsigned int fred(int x) {
50 return (x >= -4 ? x : -4) + (x <= -4 ? -x : -4);
51 }
52
53 /* Incorrect pattern. */
54 __attribute__((noipa)) unsigned int goo(int x) {
55 return (x <= 0 ? x : 0) + (x >= 0 ? -x : 0);
56 }
57
58 /* Incorrect pattern. */
59 __attribute__((noipa)) int qux(int x) {
60 return (x >= 0 ? x : 0) + (x >= 0 ? x : 0);
61 }
62
63 /* { dg-final {scan-tree-dump-times " ABS_EXPR " 6 "forwprop1" } } */