Merge lp:~ams-codesourcery/gcc-linaro/compound-conditionals into lp:gcc-linaro/4.6

Proposed by Andrew Stubbs
Status: Merged
Approved by: Ulrich Weigand
Approved revision: no longer in the source branch.
Merged at revision: 106740
Proposed branch: lp:~ams-codesourcery/gcc-linaro/compound-conditionals
Merge into: lp:gcc-linaro/4.6
Diff against target: 262 lines (+65/-28)
2 files modified
ChangeLog.linaro (+19/-0)
gcc/combine.c (+46/-28)
To merge this branch: bzr merge lp:~ams-codesourcery/gcc-linaro/compound-conditionals
Reviewer Review Type Date Requested Status
Ulrich Weigand (community) Approve
Review via email: mp+59066@code.launchpad.net

Description of the change

This is a merge of lp:gcc-linaro/4.5 r99436 to Linaro GCC 4.6.

The patch itself is a backport from upstream GCC (pre-4.7), to which it was committed by Maxim Kuvyrkov:
  http://<email address hidden>/msg03282.html

To post a comment you must log in.
Revision history for this message
Ulrich Weigand (uweigand) wrote :

For completeness, this probably also ought to include the follow-up patch Maxim committed recently:
http://gcc.gnu.org/ml/gcc-patches/2011-04/msg01961.html

Otherwise OK.

review: Approve
Revision history for this message
Linaro Toolchain Builder (cbuild) wrote :

cbuild has taken a snapshot of this branch at r106739 and queued it for build.

The snapshot is available at:
 http://ex.seabright.co.nz/snapshots/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals.tar.xdelta3.xz

and will be built on the following builders:
 a9-builder i686 x86_64

You can track the build queue at:
 http://ex.seabright.co.nz/helpers/scheduler

cbuild-snapshot: gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals
cbuild-ancestor: lp:gcc-linaro/4.6+bzr106737
cbuild-state: check

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote :

cbuild successfully built this on i686-lucid-cbuild113-scorpius-i686r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals/logs/i686-lucid-cbuild113-scorpius-i686r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106737.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals/logs/i686-lucid-cbuild113-scorpius-i686r1/gcc-testsuite.txt

cbuild-checked: i686-lucid-cbuild113-scorpius-i686r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote :

cbuild successfully built this on x86_64-maverick-cbuild113-crucis-x86_64r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals/logs/x86_64-maverick-cbuild113-crucis-x86_64r1

The test suite results were unchanged compared to the branch point lp:gcc-linaro/4.6+bzr106737.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals/logs/x86_64-maverick-cbuild113-crucis-x86_64r1/gcc-testsuite.txt

cbuild-checked: x86_64-maverick-cbuild113-crucis-x86_64r1

Revision history for this message
Linaro Toolchain Builder (cbuild) wrote :

cbuild successfully built this on armv7l-maverick-cbuild113-ursa3-cortexa9r1.

The build results are available at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals/logs/armv7l-maverick-cbuild113-ursa3-cortexa9r1

The test suite results changed compared to the branch point lp:gcc-linaro/4.6+bzr106737:
 +WARNING: program timed out.

The full testsuite results are at:
 http://ex.seabright.co.nz/build/gcc-linaro-4.6+bzr106739~ams-codesourcery~compound-conditionals/logs/armv7l-maverick-cbuild113-ursa3-cortexa9r1/gcc-testsuite.txt

cbuild-checked: armv7l-maverick-cbuild113-ursa3-cortexa9r1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog.linaro'
2--- ChangeLog.linaro 2011-04-21 13:51:06 +0000
3+++ ChangeLog.linaro 2011-04-26 17:13:42 +0000
4@@ -1,3 +1,22 @@
5+2011-04-26 Andrew Stubbs <ams@codesourcery.com>
6+
7+ Backport from FSF:
8+
9+ 2011-04-15 Maxim Kuvyrkov <maxim@codesourcery.com>
10+
11+ gcc/
12+ * combine.c (subst, combine_simlify_rtx): Add new argument, use it
13+ to track processing of conditionals. Update all callers.
14+ (try_combine, simplify_if_then_else): Update.
15+
16+ 2011-04-25 Maxim Kuvyrkov <maxim@codesourcery.com>
17+ Eric Botcazou <ebotcazou@adacore.com>
18+
19+ gcc/
20+ * combine.c (combine_simplify_rtx): Avoid mis-simplifying conditionals
21+ for STORE_FLAG_VALUE==-1 case.
22+
23+
24 2011-04-21 Andrew Stubbs <ams@codesourcery.com>
25
26 Backport from FSF:
27
28=== modified file 'gcc/combine.c'
29--- gcc/combine.c 2011-02-15 19:46:26 +0000
30+++ gcc/combine.c 2011-04-26 17:13:42 +0000
31@@ -391,8 +391,8 @@
32 static void undo_all (void);
33 static void undo_commit (void);
34 static rtx *find_split_point (rtx *, rtx, bool);
35-static rtx subst (rtx, rtx, rtx, int, int);
36-static rtx combine_simplify_rtx (rtx, enum machine_mode, int);
37+static rtx subst (rtx, rtx, rtx, int, int, int);
38+static rtx combine_simplify_rtx (rtx, enum machine_mode, int, int);
39 static rtx simplify_if_then_else (rtx);
40 static rtx simplify_set (rtx);
41 static rtx simplify_logical (rtx);
42@@ -3086,12 +3086,12 @@
43 if (i1)
44 {
45 subst_low_luid = DF_INSN_LUID (i1);
46- i1src = subst (i1src, pc_rtx, pc_rtx, 0, 0);
47+ i1src = subst (i1src, pc_rtx, pc_rtx, 0, 0, 0);
48 }
49 else
50 {
51 subst_low_luid = DF_INSN_LUID (i2);
52- i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0);
53+ i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0, 0);
54 }
55 }
56
57@@ -3103,7 +3103,7 @@
58 self-referential RTL when we will be substituting I1SRC for I1DEST
59 later. Likewise if I0 feeds into I2, either directly or indirectly
60 through I1, and I0DEST is in I0SRC. */
61- newpat = subst (PATTERN (i3), i2dest, i2src, 0,
62+ newpat = subst (PATTERN (i3), i2dest, i2src, 0, 0,
63 (i1_feeds_i2_n && i1dest_in_i1src)
64 || ((i0_feeds_i2_n || (i0_feeds_i1_n && i1_feeds_i2_n))
65 && i0dest_in_i0src));
66@@ -3142,7 +3142,7 @@
67 copy of I1SRC each time we substitute it, in order to avoid creating
68 self-referential RTL when we will be substituting I0SRC for I0DEST
69 later. */
70- newpat = subst (newpat, i1dest, i1src, 0,
71+ newpat = subst (newpat, i1dest, i1src, 0, 0,
72 i0_feeds_i1_n && i0dest_in_i0src);
73 substed_i1 = 1;
74
75@@ -3172,7 +3172,7 @@
76
77 n_occurrences = 0;
78 subst_low_luid = DF_INSN_LUID (i0);
79- newpat = subst (newpat, i0dest, i0src, 0, 0);
80+ newpat = subst (newpat, i0dest, i0src, 0, 0, 0);
81 substed_i0 = 1;
82 }
83
84@@ -3234,7 +3234,7 @@
85 {
86 rtx t = i1pat;
87 if (i0_feeds_i1_n)
88- t = subst (t, i0dest, i0src, 0, 0);
89+ t = subst (t, i0dest, i0src, 0, 0, 0);
90
91 XVECEXP (newpat, 0, --total_sets) = t;
92 }
93@@ -3242,10 +3242,10 @@
94 {
95 rtx t = i2pat;
96 if (i1_feeds_i2_n)
97- t = subst (t, i1dest, i1src_copy ? i1src_copy : i1src, 0,
98+ t = subst (t, i1dest, i1src_copy ? i1src_copy : i1src, 0, 0,
99 i0_feeds_i1_n && i0dest_in_i0src);
100 if ((i0_feeds_i1_n && i1_feeds_i2_n) || i0_feeds_i2_n)
101- t = subst (t, i0dest, i0src, 0, 0);
102+ t = subst (t, i0dest, i0src, 0, 0, 0);
103
104 XVECEXP (newpat, 0, --total_sets) = t;
105 }
106@@ -4914,11 +4914,13 @@
107
108 IN_DEST is nonzero if we are processing the SET_DEST of a SET.
109
110+ IN_COND is nonzero if we are on top level of the condition.
111+
112 UNIQUE_COPY is nonzero if each substitution must be unique. We do this
113 by copying if `n_occurrences' is nonzero. */
114
115 static rtx
116-subst (rtx x, rtx from, rtx to, int in_dest, int unique_copy)
117+subst (rtx x, rtx from, rtx to, int in_dest, int in_cond, int unique_copy)
118 {
119 enum rtx_code code = GET_CODE (x);
120 enum machine_mode op0_mode = VOIDmode;
121@@ -4979,7 +4981,7 @@
122 && GET_CODE (XVECEXP (x, 0, 0)) == SET
123 && GET_CODE (SET_SRC (XVECEXP (x, 0, 0))) == ASM_OPERANDS)
124 {
125- new_rtx = subst (XVECEXP (x, 0, 0), from, to, 0, unique_copy);
126+ new_rtx = subst (XVECEXP (x, 0, 0), from, to, 0, 0, unique_copy);
127
128 /* If this substitution failed, this whole thing fails. */
129 if (GET_CODE (new_rtx) == CLOBBER
130@@ -4996,7 +4998,7 @@
131 && GET_CODE (dest) != CC0
132 && GET_CODE (dest) != PC)
133 {
134- new_rtx = subst (dest, from, to, 0, unique_copy);
135+ new_rtx = subst (dest, from, to, 0, 0, unique_copy);
136
137 /* If this substitution failed, this whole thing fails. */
138 if (GET_CODE (new_rtx) == CLOBBER
139@@ -5042,8 +5044,8 @@
140 }
141 else
142 {
143- new_rtx = subst (XVECEXP (x, i, j), from, to, 0,
144- unique_copy);
145+ new_rtx = subst (XVECEXP (x, i, j), from, to, 0, 0,
146+ unique_copy);
147
148 /* If this substitution failed, this whole thing
149 fails. */
150@@ -5120,7 +5122,9 @@
151 && (code == SUBREG || code == STRICT_LOW_PART
152 || code == ZERO_EXTRACT))
153 || code == SET)
154- && i == 0), unique_copy);
155+ && i == 0),
156+ code == IF_THEN_ELSE && i == 0,
157+ unique_copy);
158
159 /* If we found that we will have to reject this combination,
160 indicate that by returning the CLOBBER ourselves, rather than
161@@ -5177,7 +5181,7 @@
162 /* If X is sufficiently simple, don't bother trying to do anything
163 with it. */
164 if (code != CONST_INT && code != REG && code != CLOBBER)
165- x = combine_simplify_rtx (x, op0_mode, in_dest);
166+ x = combine_simplify_rtx (x, op0_mode, in_dest, in_cond);
167
168 if (GET_CODE (x) == code)
169 break;
170@@ -5197,10 +5201,12 @@
171 expression.
172
173 OP0_MODE is the original mode of XEXP (x, 0). IN_DEST is nonzero
174- if we are inside a SET_DEST. */
175+ if we are inside a SET_DEST. IN_COND is nonzero if we are on the top level
176+ of a condition. */
177
178 static rtx
179-combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int in_dest)
180+combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int in_dest,
181+ int in_cond)
182 {
183 enum rtx_code code = GET_CODE (x);
184 enum machine_mode mode = GET_MODE (x);
185@@ -5255,8 +5261,8 @@
186 false arms to store-flag values. Be careful to use copy_rtx
187 here since true_rtx or false_rtx might share RTL with x as a
188 result of the if_then_else_cond call above. */
189- true_rtx = subst (copy_rtx (true_rtx), pc_rtx, pc_rtx, 0, 0);
190- false_rtx = subst (copy_rtx (false_rtx), pc_rtx, pc_rtx, 0, 0);
191+ true_rtx = subst (copy_rtx (true_rtx), pc_rtx, pc_rtx, 0, 0, 0);
192+ false_rtx = subst (copy_rtx (false_rtx), pc_rtx, pc_rtx, 0, 0, 0);
193
194 /* If true_rtx and false_rtx are not general_operands, an if_then_else
195 is unlikely to be simpler. */
196@@ -5600,7 +5606,7 @@
197 {
198 /* Try to simplify the expression further. */
199 rtx tor = simplify_gen_binary (IOR, mode, XEXP (x, 0), XEXP (x, 1));
200- temp = combine_simplify_rtx (tor, mode, in_dest);
201+ temp = combine_simplify_rtx (tor, mode, in_dest, 0);
202
203 /* If we could, great. If not, do not go ahead with the IOR
204 replacement, since PLUS appears in many special purpose
205@@ -5693,7 +5699,16 @@
206 ZERO_EXTRACT is indeed appropriate, it will be placed back by
207 the call to make_compound_operation in the SET case. */
208
209- if (STORE_FLAG_VALUE == 1
210+ if (in_cond)
211+ /* Don't apply below optimizations if the caller would
212+ prefer a comparison rather than a value.
213+ E.g., for the condition in an IF_THEN_ELSE most targets need
214+ an explicit comparison. */
215+ {
216+ ;
217+ }
218+
219+ else if (STORE_FLAG_VALUE == 1
220 && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT
221 && op1 == const0_rtx
222 && mode == GET_MODE (op0)
223@@ -5739,7 +5754,10 @@
224
225 /* If STORE_FLAG_VALUE is -1, we have cases similar to
226 those above. */
227- if (STORE_FLAG_VALUE == -1
228+ if (in_cond)
229+ ;
230+
231+ else if (STORE_FLAG_VALUE == -1
232 && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT
233 && op1 == const0_rtx
234 && (num_sign_bit_copies (op0, mode)
235@@ -5937,11 +5955,11 @@
236 if (reg_mentioned_p (from, true_rtx))
237 true_rtx = subst (known_cond (copy_rtx (true_rtx), true_code,
238 from, true_val),
239- pc_rtx, pc_rtx, 0, 0);
240+ pc_rtx, pc_rtx, 0, 0, 0);
241 if (reg_mentioned_p (from, false_rtx))
242 false_rtx = subst (known_cond (copy_rtx (false_rtx), false_code,
243 from, false_val),
244- pc_rtx, pc_rtx, 0, 0);
245+ pc_rtx, pc_rtx, 0, 0, 0);
246
247 SUBST (XEXP (x, 1), swapped ? false_rtx : true_rtx);
248 SUBST (XEXP (x, 2), swapped ? true_rtx : false_rtx);
249@@ -6158,11 +6176,11 @@
250 {
251 temp = subst (simplify_gen_relational (true_code, m, VOIDmode,
252 cond_op0, cond_op1),
253- pc_rtx, pc_rtx, 0, 0);
254+ pc_rtx, pc_rtx, 0, 0, 0);
255 temp = simplify_gen_binary (MULT, m, temp,
256 simplify_gen_binary (MULT, m, c1,
257 const_true_rtx));
258- temp = subst (temp, pc_rtx, pc_rtx, 0, 0);
259+ temp = subst (temp, pc_rtx, pc_rtx, 0, 0, 0);
260 temp = simplify_gen_binary (op, m, gen_lowpart (m, z), temp);
261
262 if (extend_op != UNKNOWN)

Subscribers

People subscribed via source and target branches