This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix disable-checking bootstrap comparison failure i686-pc-linux-gnu


Severe braindamage on my part -- worse yet, I identified this as a problem
in a later patch (phi->abs_expr optimization), but didn't go back and fix
the earlier changes to tree-ssa-phiopt.

Basically we've got something like

bb0:
if (x != 0) goto bb1 else goto bb2

bb1:

bb2:
  y = phi (x (bb1), 0 (bb0))

We want to turn that into

bb0:
bb1:
bb2:
  y = x;


We incorrectly turned it into y = 0;


Basically we want the RHS of the new assignment to have the PHI argument
which is associated with the true edge out of bb0.  However, we failed to
account for the fact that the true edge out of bb0 might pass through
the intermediate empty block before reaching the PHI.

This patch fixes the problem and adds some comments which ought to make the
code a little clearer.

Bootstrapped and regression tested on i686-pc-linux-gnu (--disable-checking,
which is where the bug exposed itself).

	* tree-ssa-phiopt.c (value_replacement): Handle the case where
	the desired edge out of COND_BLOCK reaches OTHER_BLOCK rather than
	BB directly.

Index: tree-ssa-phiopt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-phiopt.c,v
retrieving revision 2.6
diff -c -p -r2.6 tree-ssa-phiopt.c
*** tree-ssa-phiopt.c	19 May 2004 03:35:10 -0000	2.6
--- tree-ssa-phiopt.c	19 May 2004 18:25:22 -0000
*************** value_replacement (basic_block bb, tree 
*** 464,470 ****
--- 464,483 ----
        edge e;
        tree arg;
  
+       /* For NE_EXPR, we want to build an assignment result = arg where
+ 	 arg is the PHI argument associated with the true edge.  For
+ 	 EQ_EXPR we want the PHI argument associated with the false edge.  */
        e = (TREE_CODE (cond) == NE_EXPR ? true_edge : false_edge);
+ 
+       /* Unfortunately, E may not reach BB (it may instead have gone to
+ 	 OTHER_BLOCK).  If that is the case, then we want the single outgoing
+ 	 edge from OTHER_BLOCK which reaches BB and represents the desired
+ 	 path from COND_BLOCK.  */
+       if (e->dest == other_block)
+ 	e = e->dest->succ;
+ 
+       /* Now we know the incoming edge to BB that has the argument for the
+ 	 RHS of our new assignment statement.  */
        if (PHI_ARG_EDGE (phi, 0) == e)
  	arg = arg0;
        else











Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]