This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] restore bootstrap on ppc
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 11 Sep 2007 14:48:07 +0200
- Subject: [patch] restore bootstrap on ppc
Hello,
at the moment, boostrap on ppc fails due to the following problem in
constant folding: it is asked to simplify 64x-8.
fold_plusminus_mult_expr changes this to (-8x + 1) * (-8),
then extract_muldiv changes it back to 64x-8, and they do it
back and forth several times (which by itself is silly, but not the
cause of the problem), until the counter in extract_muldiv_1
makes it fail (to prevent infinite cycle). This failure makes the
code affected by the patch reached. The code is supposed to
handle simplifications like 8*x/8 = x, however, it does not test
whether the division operator is not in fact MULT_EXPR; so when
reached, it simplifies (-8) * x * (-8) to x, which causes
misscompilation.
The patch below was bootstrapped & regtested on i686, and reported to
restore bootstrap on ppc. I will commit it as obvious.
Zdenek
* fold-const.c (extract_muldiv_1): Do not simplify
var * c * c to var.
Index: fold-const.c
===================================================================
*** fold-const.c (revision 128320)
--- fold-const.c (working copy)
*************** extract_muldiv_1 (tree t, tree c, enum t
*** 6273,6279 ****
&& ((code == MULT_EXPR && tcode == EXACT_DIV_EXPR)
|| (tcode == MULT_EXPR
&& code != TRUNC_MOD_EXPR && code != CEIL_MOD_EXPR
! && code != FLOOR_MOD_EXPR && code != ROUND_MOD_EXPR)))
{
if (integer_zerop (const_binop (TRUNC_MOD_EXPR, op1, c, 0)))
{
--- 6273,6280 ----
&& ((code == MULT_EXPR && tcode == EXACT_DIV_EXPR)
|| (tcode == MULT_EXPR
&& code != TRUNC_MOD_EXPR && code != CEIL_MOD_EXPR
! && code != FLOOR_MOD_EXPR && code != ROUND_MOD_EXPR
! && code != MULT_EXPR)))
{
if (integer_zerop (const_binop (TRUNC_MOD_EXPR, op1, c, 0)))
{