diff options
Diffstat (limited to 'toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99452.patch')
-rw-r--r-- | toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99452.patch | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99452.patch b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99452.patch new file mode 100644 index 0000000000..6cfc01feff --- /dev/null +++ b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99452.patch | |||
@@ -0,0 +1,201 @@ | |||
1 | 2010-12-14 Sandra Loosemore <sandra@codesourcery.com> | ||
2 | |||
3 | Backport from mainline: | ||
4 | |||
5 | 2010-12-14 Jakub Jelinek <jakub@redhat.com> | ||
6 | |||
7 | PR tree-optimization/46909 | ||
8 | |||
9 | gcc/ | ||
10 | * tree-ssa-ccp.c (and_var_with_comparison_1): Save partial | ||
11 | result even in the is_and case, if both partial results | ||
12 | are the same, return it. | ||
13 | (or_var_with_comparison_1): Use is_or predicate instead of | ||
14 | innercode == TRUTH_OR_EXPR test. Save partial result | ||
15 | even in the is_or case, if both partial results are the | ||
16 | same, return it. In the !is_or case when both partial | ||
17 | results are the same, return the partial result instead | ||
18 | of boolean_true_node. | ||
19 | |||
20 | gcc/testsuite/ | ||
21 | * gcc.c-torture/execute/pr46909-1.c: New test. | ||
22 | * gcc.c-torture/execute/pr46909-2.c: New test. | ||
23 | * gcc.dg/pr46909.c: New test. | ||
24 | |||
25 | === added file 'gcc/testsuite/gcc.c-torture/execute/pr46909-1.c' | ||
26 | --- old/gcc/testsuite/gcc.c-torture/execute/pr46909-1.c 1970-01-01 00:00:00 +0000 | ||
27 | +++ new/gcc/testsuite/gcc.c-torture/execute/pr46909-1.c 2011-01-05 11:27:00 +0000 | ||
28 | @@ -0,0 +1,22 @@ | ||
29 | +/* PR tree-optimization/46909 */ | ||
30 | + | ||
31 | +extern void abort (); | ||
32 | + | ||
33 | +int | ||
34 | +__attribute__ ((__noinline__)) | ||
35 | +foo (unsigned int x) | ||
36 | +{ | ||
37 | + if (! (x == 4 || x == 6) || (x == 2 || x == 6)) | ||
38 | + return 1; | ||
39 | + return -1; | ||
40 | +} | ||
41 | + | ||
42 | +int | ||
43 | +main () | ||
44 | +{ | ||
45 | + int i; | ||
46 | + for (i = -10; i < 10; i++) | ||
47 | + if (foo (i) != 1 - 2 * (i == 4)) | ||
48 | + abort (); | ||
49 | + return 0; | ||
50 | +} | ||
51 | |||
52 | === added file 'gcc/testsuite/gcc.c-torture/execute/pr46909-2.c' | ||
53 | --- old/gcc/testsuite/gcc.c-torture/execute/pr46909-2.c 1970-01-01 00:00:00 +0000 | ||
54 | +++ new/gcc/testsuite/gcc.c-torture/execute/pr46909-2.c 2011-01-05 11:27:00 +0000 | ||
55 | @@ -0,0 +1,22 @@ | ||
56 | +/* PR tree-optimization/46909 */ | ||
57 | + | ||
58 | +extern void abort (void); | ||
59 | + | ||
60 | +int | ||
61 | +__attribute__((noinline)) | ||
62 | +foo (int x) | ||
63 | +{ | ||
64 | + if ((x != 0 && x != 13) || x == 5 || x == 20) | ||
65 | + return 1; | ||
66 | + return -1; | ||
67 | +} | ||
68 | + | ||
69 | +int | ||
70 | +main (void) | ||
71 | +{ | ||
72 | + int i; | ||
73 | + for (i = -10; i < 30; i++) | ||
74 | + if (foo (i) != 1 - 2 * (i == 0) - 2 * (i == 13)) | ||
75 | + abort (); | ||
76 | + return 0; | ||
77 | +} | ||
78 | |||
79 | === added file 'gcc/testsuite/gcc.dg/pr46909.c' | ||
80 | --- old/gcc/testsuite/gcc.dg/pr46909.c 1970-01-01 00:00:00 +0000 | ||
81 | +++ new/gcc/testsuite/gcc.dg/pr46909.c 2011-01-05 11:27:00 +0000 | ||
82 | @@ -0,0 +1,17 @@ | ||
83 | +/* PR tree-optimization/46909 */ | ||
84 | +/* { dg-do compile } */ | ||
85 | +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ | ||
86 | + | ||
87 | +extern void abort (); | ||
88 | + | ||
89 | +int | ||
90 | +__attribute__ ((__noinline__)) | ||
91 | +foo (unsigned int x) | ||
92 | +{ | ||
93 | + if (! (x == 4 || x == 6) || (x == 2 || x == 6)) | ||
94 | + return 1; | ||
95 | + return -1; | ||
96 | +} | ||
97 | + | ||
98 | +/* { dg-final { scan-tree-dump "optimizing two comparisons to x_\[0-9\]+\\(D\\) != 4" "ifcombine" } } */ | ||
99 | +/* { dg-final { cleanup-tree-dump "ifcombine" } } */ | ||
100 | |||
101 | === modified file 'gcc/tree-ssa-ccp.c' | ||
102 | --- old/gcc/tree-ssa-ccp.c 2010-09-16 09:15:46 +0000 | ||
103 | +++ new/gcc/tree-ssa-ccp.c 2011-01-05 11:27:00 +0000 | ||
104 | @@ -3508,14 +3508,11 @@ | ||
105 | /* Handle the OR case, where we are redistributing: | ||
106 | (inner1 OR inner2) AND (op2a code2 op2b) | ||
107 | => (t OR (inner2 AND (op2a code2 op2b))) */ | ||
108 | - else | ||
109 | - { | ||
110 | - if (integer_onep (t)) | ||
111 | - return boolean_true_node; | ||
112 | - else | ||
113 | - /* Save partial result for later. */ | ||
114 | - partial = t; | ||
115 | - } | ||
116 | + else if (integer_onep (t)) | ||
117 | + return boolean_true_node; | ||
118 | + | ||
119 | + /* Save partial result for later. */ | ||
120 | + partial = t; | ||
121 | } | ||
122 | |||
123 | /* Compute the second partial result, (inner2 AND (op2a code op2b)) */ | ||
124 | @@ -3536,6 +3533,10 @@ | ||
125 | return inner1; | ||
126 | else if (integer_zerop (t)) | ||
127 | return boolean_false_node; | ||
128 | + /* If both are the same, we can apply the identity | ||
129 | + (x AND x) == x. */ | ||
130 | + else if (partial && same_bool_result_p (t, partial)) | ||
131 | + return t; | ||
132 | } | ||
133 | |||
134 | /* Handle the OR case. where we are redistributing: | ||
135 | @@ -3945,7 +3946,7 @@ | ||
136 | => (t OR inner2) | ||
137 | If the partial result t is a constant, we win. Otherwise | ||
138 | continue on to try reassociating with the other inner test. */ | ||
139 | - if (innercode == TRUTH_OR_EXPR) | ||
140 | + if (is_or) | ||
141 | { | ||
142 | if (integer_onep (t)) | ||
143 | return boolean_true_node; | ||
144 | @@ -3956,14 +3957,11 @@ | ||
145 | /* Handle the AND case, where we are redistributing: | ||
146 | (inner1 AND inner2) OR (op2a code2 op2b) | ||
147 | => (t AND (inner2 OR (op2a code op2b))) */ | ||
148 | - else | ||
149 | - { | ||
150 | - if (integer_zerop (t)) | ||
151 | - return boolean_false_node; | ||
152 | - else | ||
153 | - /* Save partial result for later. */ | ||
154 | - partial = t; | ||
155 | - } | ||
156 | + else if (integer_zerop (t)) | ||
157 | + return boolean_false_node; | ||
158 | + | ||
159 | + /* Save partial result for later. */ | ||
160 | + partial = t; | ||
161 | } | ||
162 | |||
163 | /* Compute the second partial result, (inner2 OR (op2a code op2b)) */ | ||
164 | @@ -3977,13 +3975,18 @@ | ||
165 | { | ||
166 | /* Handle the OR case, where we are reassociating: | ||
167 | (inner1 OR inner2) OR (op2a code2 op2b) | ||
168 | - => (inner1 OR t) */ | ||
169 | - if (innercode == TRUTH_OR_EXPR) | ||
170 | + => (inner1 OR t) | ||
171 | + => (t OR partial) */ | ||
172 | + if (is_or) | ||
173 | { | ||
174 | if (integer_zerop (t)) | ||
175 | return inner1; | ||
176 | else if (integer_onep (t)) | ||
177 | return boolean_true_node; | ||
178 | + /* If both are the same, we can apply the identity | ||
179 | + (x OR x) == x. */ | ||
180 | + else if (partial && same_bool_result_p (t, partial)) | ||
181 | + return t; | ||
182 | } | ||
183 | |||
184 | /* Handle the AND case, where we are redistributing: | ||
185 | @@ -4000,13 +4003,13 @@ | ||
186 | operand to the redistributed AND expression. The | ||
187 | interesting case is when at least one is true. | ||
188 | Or, if both are the same, we can apply the identity | ||
189 | - (x AND x) == true. */ | ||
190 | + (x AND x) == x. */ | ||
191 | if (integer_onep (partial)) | ||
192 | return t; | ||
193 | else if (integer_onep (t)) | ||
194 | return partial; | ||
195 | else if (same_bool_result_p (t, partial)) | ||
196 | - return boolean_true_node; | ||
197 | + return t; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | |||