[PATCH] PR bootstrap/12358: Operand reordering problems.

Roger Sayle roger@eyesopen.com
Tue Sep 23 15:27:00 GMT 2003


The following patch fixes PR bootstrap/12358 which causes a stage2/stage3
comparison failure bootstrapping on hppa64-hp-hpux11.11, and should also
cure the current miscompilation of the GNU crypto library by gcj.

I'll admit that this "fix" is really a temporary work around that doesn't
directly address the underlying issues.  For the bootstrap failure, there
must be an operand ordering assumption in the source code or some bad
interaction in the RTL optimizers caused by changing the order of these
operands.  For gcj, there needs to be some way that the java front-end
request that we not change the evaluation order of operands (my proposed
flag_evaluation_order global), as gcj's force_evaluation_order function
currently makes unwarranted assumptions about GCC's middle-end and
back-end.  Both of these I intend to fix very shortly, but this patch
gets things working again for mainline.

I fully understand if a reviewer request that we fix the real causes
rather than provide a "band-aid" workaround.  This patch is posted so
that some kind of fix is available for these regressions before we
enter stage 3.  stage3 failures and miscomparisons are notoriously
tricky to track down, so even identifying the errant code may take
time.  Many thanks to Andrew Pinski for volunteering to help track
down some of GCC's operand ordering bugs.

Many thanks to David Anglin for confirming that this patch restores
bootstrap on hppa64-hp-hpux11.11.  In addition, I've also tested the
patch with a complete "make bootstrap", all languages except treelang,
on i686-pc-linux-gnu with a top-level "make -k check" with no new
failures.

Ok for mainline?

2003-09-23  Roger Sayle  <roger@eyesopen.com>

	PR bootstrap/12358
	* fold-const.c (tree_swap_operands_p): Only reorder operands when
	one of the operands is constant.


Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.305
diff -c -3 -p -r1.305 fold-const.c
*** fold-const.c	18 Sep 2003 15:05:53 -0000	1.305
--- fold-const.c	23 Sep 2003 02:22:52 -0000
*************** tree_swap_operands_p (tree arg0, tree ar
*** 5007,5022 ****
    if (TREE_CONSTANT (arg0))
      return 1;

-   if (DECL_P (arg1))
-     return 0;
-   if (DECL_P (arg0))
-     return 1;
-
-   if (TREE_CODE (arg1) == SAVE_EXPR)
-     return 0;
-   if (TREE_CODE (arg0) == SAVE_EXPR)
-     return 1;
-
    return 0;
  }

--- 5007,5012 ----

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list