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