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]

gcc3.0 loop.c patch for IA-64 linux kernel miscompilation


This is a patch for PR 3128, which is a bit of code extracted from the IA-64
linux kernel.

This gets miscompiled as a side-effect of the relatively new code Richard
Henderson added last fall to detect GIVs which are derived by extension
operations.  If we find a value that is a potential extension dependent
GIV, and then later determine we can't reduce it, we need to note that we
haven't reduced all GIVs.  Otherwise, loop thinks that there are no longer
any references to the base BIV and will eliminate it.  This leaves a GIV
with a dangling reference to the eliminated BIV, and this use of an unitialized
register causes the resulting code to fail at run time.

This was tested with an ia64-linux bootstrap and testsuite run, with and
without this patch.  There were no regressions caused by the patch.  The
patch does fix the testcase in the PR.  This testcase needs a little modifying
before it can go into the gcc testsuite.  I plan to do that tomorrow.

2001-06-12  Jim Wilson  <wilson@redhat.com>

	* loop.c (strength_reduce): Move bl->all_reduced set before
	check_ext_dependant_givs call.
	(check_ext_dependant_givs): Clear bl->all_reduced when ignoring givs.

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.322.4.9
diff -p -r1.322.4.9 loop.c
*** loop.c	2001/05/12 20:32:37	1.322.4.9
--- loop.c	2001/06/13 02:43:47
*************** strength_reduce (loop, flags)
*** 4304,4309 ****
--- 4304,4314 ----
  	 provided all givs are reduced.  */
        bl->eliminable = loop_biv_eliminable_p (loop, bl, threshold, insn_count);
  
+       /* This will be true at the end, if all givs which depend on this
+ 	 biv have been strength reduced.
+ 	 We can't (currently) eliminate the biv unless this is so.  */
+       bl->all_reduced = 1;
+ 
        /* Check each extension dependent giv in this class to see if its
  	 root biv is safe from wrapping in the interior mode.  */
        check_ext_dependant_givs (bl, loop_info);
*************** strength_reduce (loop, flags)
*** 4311,4321 ****
        /* Combine all giv's for this iv_class.  */
        combine_givs (regs, bl);
  
-       /* This will be true at the end, if all givs which depend on this
- 	 biv have been strength reduced.
- 	 We can't (currently) eliminate the biv unless this is so.  */
-       bl->all_reduced = 1;
- 
        for (v = bl->giv; v; v = v->next_iv)
  	{
  	  struct induction *tv;
--- 4316,4321 ----
*************** check_ext_dependant_givs (bl, loop_info)
*** 6646,6651 ****
--- 6646,6652 ----
  			 INSN_UID (v->insn), why);
  	      }
  	    v->ignore = 1;
+ 	    bl->all_reduced = 0;
  	  }
        }
  }


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