This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix possible FP reassociation problem in simplify-rtx.c
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 1 Dec 2005 14:55:55 +1030
- Subject: Re: [PATCH] fix possible FP reassociation problem in simplify-rtx.c
- References: <dm2stk$oh4$1@sea.gmane.org>
On Thu, Nov 24, 2005 at 12:12:05AM +0100, Paolo Bonzini wrote:
> * simplify-rtx.c (simplify_plus_minus): Remove final parameter.
> Always produce an output if we can remove NEGs or canonicalize
> (minus (minus ...)) expressions. Provide a fast path for the
> two-operand case.
> (simplify_gen_binary): Do not call simplify_plus_minus.
> (simplify_binary_operation_1): Reassociate at the end of the
> function.
This breaks rs6000_frame_related, which expects reg+const1+const2 to be
simplified. Testing the following.
* simplify-rtx.c (simplify_plus_minus): Do simplify constants.
Delete dead code.
Index: gcc/simplify-rtx.c
===================================================================
--- gcc/simplify-rtx.c (revision 107758)
+++ gcc/simplify-rtx.c (working copy)
@@ -2602,7 +2602,7 @@ simplify_plus_minus (enum rtx_code code,
{
struct simplify_plus_minus_op_data ops[8];
rtx result, tem;
- int n_ops = 2, input_ops = 2, input_consts = 0, n_consts;
+ int n_ops = 2, input_ops = 2, input_consts = 0;
int first, changed, canonicalized = 0;
int i, j;
@@ -2699,7 +2699,16 @@ simplify_plus_minus (enum rtx_code code,
gcc_assert (n_ops >= 2);
if (!canonicalized)
- return NULL_RTX;
+ {
+ int n_constants = 0;
+
+ for (i = 0; i < n_ops; i++)
+ if (GET_CODE (ops[i].op) == CONST_INT)
+ n_constants++;
+
+ if (n_constants <= 1)
+ return NULL_RTX;
+ }
/* If we only have two operands, we can avoid the loops. */
if (n_ops == 2)
@@ -2835,12 +2844,6 @@ simplify_plus_minus (enum rtx_code code,
n_ops--;
}
- /* Count the number of CONSTs that we generated. */
- n_consts = 0;
- for (i = 0; i < n_ops; i++)
- if (GET_CODE (ops[i].op) == CONST)
- n_consts++;
-
/* Put a non-negated operand first, if possible. */
for (i = 0; i < n_ops && ops[i].neg; i++)
--
Alan Modra
IBM OzLabs - Linux Technology Centre