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]

Re: [PATCH] Fix PR optimization/6713


On Mon, Jun 17, 2002 at 09:55:45PM +0200, Eric Botcazou wrote:
> The proposed fix is to explicitly delete insn #2 when issuing insn #4.
> Bootstrapped/regtested (C/C++) on i586-pc-linux-gnu (gcc-3_1-branch).

The analysis is nearly, but not quite correct.  The problem
is not that delete_trivially_dead_insns did or did not remove
the instruction.  The problem is that REG_EQUAL means that 
the source is set exactly once, and is valid across the entire
function.  Which isn't true anymore, since we've just added
a second set.

I thought about removing just the note.  That does in fact
solve the problem, but we know for a fact that the insn is
dead and the two sets confuses the rest of the loop optimizer.

So I'm considering the following adjustment of the commentary.

Unfortunately, the given test case doesn't go through this 
path on mainline and so passes for completely different reasons.
I'm going to go ahead and apply the patch there anyway, since
I don't see anything that invalidates the analysis.

Mark, ok for 3.1?


r~



Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.389.2.7
diff -c -p -d -r1.389.2.7 loop.c
*** loop.c	15 Jun 2002 01:12:04 -0000	1.389.2.7
--- loop.c	17 Jul 2002 00:27:24 -0000
*************** loop_givs_rescan (loop, bl, reg_map)
*** 4784,4793 ****
  	}
        else
  	{
  	  /* Not replaceable; emit an insn to set the original giv reg from
  	     the reduced giv, same as above.  */
! 	  loop_insn_emit_after (loop, 0, v->insn,
! 				gen_move_insn (v->dest_reg, v->new_reg));
  	}
  
        /* When a loop is reversed, givs which depend on the reversed
--- 4784,4803 ----
  	}
        else
  	{
+ 	  rtx original_insn = v->insn;
+ 
  	  /* Not replaceable; emit an insn to set the original giv reg from
  	     the reduced giv, same as above.  */
! 	  v->insn = loop_insn_emit_after (loop, 0, original_insn,
! 					  gen_move_insn (v->dest_reg,
! 							 v->new_reg));
! 
! 	  /* The original insn may have a REG_EQUAL note.  This note is
! 	     now incorrect and may result in invalid substitutions later.
! 	     We could just delete the note, but we know that the entire
! 	     insn is dead, so we might as well save ourselves the bother
! 	     and remove the whole thing.  */
! 	  delete_insn (original_insn);
  	}
  
        /* When a loop is reversed, givs which depend on the reversed


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