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]

[PATCH] Fix variable_initial_value


Hello,

there is an error in variable_initial_value that causes it to accept
for example x + 42 as a valid initial value for x if x = x + 42 insn
is found; this may cause the number of iterations of the loop to be
determined incorrectly and a miscompilation with -funroll-loops.
I am commiting the obvious patch to fix it.

Zdenek

	* cfgloopanal.c (variable_initial_value): Update the set of
	altered registers correctly.

Index: cfgloopanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopanal.c,v
retrieving revision 1.1.6.3
diff -c -3 -p -r1.1.6.3 cfgloopanal.c
*** cfgloopanal.c	3 Jun 2003 08:24:01 -0000	1.1.6.3
--- cfgloopanal.c	11 Jun 2003 11:10:33 -0000
*************** variable_initial_value (insn, invariant_
*** 357,368 ****
      {
        for (; insn != bb->head; insn = PREV_INSN (insn))
  	{
- 	  if (modified_between_p (var, PREV_INSN (insn), NEXT_INSN (insn)))
- 	    break;
  	  if (INSN_P (insn))
  	    note_stores (PATTERN (insn),
  		(void (*) PARAMS ((rtx, rtx, void *))) unmark_altered,
  		invariant_regs);
  	}
  
        if (insn != bb->head)
--- 357,368 ----
      {
        for (; insn != bb->head; insn = PREV_INSN (insn))
  	{
  	  if (INSN_P (insn))
  	    note_stores (PATTERN (insn),
  		(void (*) PARAMS ((rtx, rtx, void *))) unmark_altered,
  		invariant_regs);
+ 	  if (modified_between_p (var, PREV_INSN (insn), NEXT_INSN (insn)))
+ 	    break;
  	}
  
        if (insn != bb->head)


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