1 /* PR tree-optimization/94920 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wno-psabi -fdump-tree-forwprop1" } */
5 typedef int __attribute__((vector_size(4*sizeof(int)))) vint;
8 __attribute__((noipa)) unsigned int foo(int x) {
9 return (x >= 0 ? x : 0) + (x <= 0 ? -x : 0);
12 /* Test for forward propogation. */
13 __attribute__((noipa)) unsigned int corge(int x) {
14 int w = (x >= 0 ? x : 0);
16 int z = (y >= 0 ? y : 0);
21 __attribute__((noipa)) vint thud(vint x) {
22 vint t = (x >= 0 ? x : 0) ;
24 vint t1 = (xx >= 0 ? xx : 0);
28 /* Signed function. */
29 __attribute__((noipa)) int bar(int x) {
30 return (x >= 0 ? x : 0) + (x <= 0 ? -x : 0);
33 /* Commutative property. */
34 __attribute__((noipa)) unsigned int baz(int x) {
35 return (x <= 0 ? -x : 0) + (x >= 0 ? x : 0);
38 /* Flipped order for max expressions. */
39 __attribute__((noipa)) unsigned int quux(int x) {
40 return (0 <= x ? x : 0) + (0 >= x ? -x : 0);
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);
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);
53 /* Incorrect pattern. */
54 __attribute__((noipa)) unsigned int goo(int x) {
55 return (x <= 0 ? x : 0) + (x >= 0 ? -x : 0);
58 /* Incorrect pattern. */
59 __attribute__((noipa)) int qux(int x) {
60 return (x >= 0 ? x : 0) + (x >= 0 ? x : 0);
63 /* { dg-final {scan-tree-dump-times " ABS_EXPR " 6 "forwprop1" } } */