User account creation filtered due to spam.
with your patch:
simplify_plus_minus isn't able anymore to simplify things like (r1 + 8) - r1.
The function is left at:
int n_constants = 0;
for (i = 0; i < n_ops; i++)
if (GET_CODE (ops[i].op) == CONST_INT)
if (n_constants <= 1)
because only a single constant was found and no canonicalization took place.
Your patch changed:
if (n_ops <= 2 && !force)
gcc_assert (n_ops >= 2);
Which was later on changed by Alan Modra with:
to the version mentioned above. The reason here was that expressions
like reg + c1 + c2 were not simplified anymore.
So the new version exits always if the initial loop couldn't do any
canonicalization work and only 0 or 1 constants are left. What prevents
simplification in all those cases.
As Roger Sayle pointed out the patch I've proposed in the email isn't the
proper fix for this issue.
Paolo Bonzini already proposed a solution in:
Thats why I'll assign the bug to him.
Uhm, fixing this will resurface a wrong-code bug, PR28651, which is more important than this missed optimization. :-(
Created attachment 12062 [details]
patch being tested
Tested so far by checking that it makes PR28651 resurface...
Being bootstrapped and tested on i686-pc-linux-gnu.
Subject: Bug 26847
Date: Tue Sep 5 17:41:22 2006
New Revision: 116701
2006-09-05 Paolo Bonzini <firstname.lastname@example.org>
* simplify-rtx.c (struct simplify_plus_minus_op_data): Remove ix.
(simplify_plus_minus_op_data_cmp): For REGs, break ties on the regno.
(simplify_plus_minus): Count n_constants while filling ops. Replace
qsort with insertion sort. Before going through the array to simplify
pairs, sort it. Delay early exit until after the first sort, exiting
only if no swaps occurred. Simplify pairs in reversed order, without
special-casing the first iteration. Pack ops after simplifying pairs.
patch committed, confirmed fixed by andreas