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]

[tree-ssa] Fix PR 14470


Not the real fix, unfortunately.  In
http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00927.html  Jason suggests
forcing minimal lvalues when gimplifying post-modify expressions.

That approach exposes a bug in the alias analyzer that is proving pretty
invasive to fix.  So, I agreed with Jason to go with this fix for the
time being and address the alias problem after the merge into mainline
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15262).

Bootstrapped and tested x86, x86-64 and ia64.  Fixes
gcc.c-torture/execute/20040313-1.c on the branch.


Diego.


2004-05-03  Diego Novillo  <dnovillo@redhat.com>

	* gimplify.c (gimplify_compound_lval): Gimplify non-constant
	array indices into a temporary variable.

testsuite/ChangeLog.tree-ssa:

	* gcc.dg/tree-ssa/20040430-1.c: New test.

Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.149
diff -d -c -p -r1.1.2.149 gimplify.c
*** gimplify.c	1 May 2004 21:55:56 -0000	1.1.2.149
--- gimplify.c	3 May 2004 14:29:32 -0000
*************** gimplify_compound_lval (tree *expr_p, tr
*** 1731,1740 ****
  	{
  	  /* Gimplify the dimension.  */
  	  enum gimplify_status tret;
! 	  tret = gimplify_expr (&TREE_OPERAND (t, 1), pre_p, post_p,
! 				is_gimple_val, fb_rvalue);
! 	  if (tret == GS_ERROR)
! 	    ret = GS_ERROR;
  	}
        recalculate_side_effects (t);
        VARRAY_POP (stack);
--- 1731,1751 ----
  	{
  	  /* Gimplify the dimension.  */
  	  enum gimplify_status tret;
! 	  /* Temporary fix for gcc.c-torture/execute/20040313-1.c.
! 	     Gimplify non-constant array indices into a temporary
! 	     variable.
! 	     FIXME - The real fix is to gimplify post-modify
! 	     expressions into a minimal gimple lvalue.  However, that
! 	     exposes bugs in alias analysis.  The alias analyzer does
! 	     not handle &PTR->FIELD very well.  Will fix after the
! 	     branch is merged into mainline (dnovillo 2004-05-03).  */
! 	  if (!is_gimple_min_invariant (TREE_OPERAND (t, 1)))
! 	    {
! 	      tret = gimplify_expr (&TREE_OPERAND (t, 1), pre_p, post_p,
! 				    is_gimple_tmp_var, fb_rvalue);
! 	      if (tret == GS_ERROR)
! 		ret = GS_ERROR;
! 	    }
  	}
        recalculate_side_effects (t);
        VARRAY_POP (stack);
Index: testsuite/gcc.dg/tree-ssa/20040430-1.c
===================================================================
RCS file: testsuite/gcc.dg/tree-ssa/20040430-1.c
diff -N testsuite/gcc.dg/tree-ssa/20040430-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/tree-ssa/20040430-1.c	3 May 2004 14:29:43 -0000
***************
*** 0 ****
--- 1,25 ----
+ /* PR middle-end/14470.  Similar to
+    gcc.c-torture/execute/20040313-1.c, but with a compile time test to
+    make sure the second if() is removed.  We should actually get rid
+    of the first if() too, but we're not that smart yet.  */
+ 
+ /* { dg-do run } */
+ /* { dg-options "-O2 -fdump-tree-optimized" } */
+ 
+ 
+ extern void abort(void);
+ 
+ int main()
+ {
+   int t[1025] = { 1024 }, d;
+ 
+   d = 0;
+   d = t[d]++;
+   if (t[0] != 1025)
+     abort();
+   if (d != 1024)
+     abort();
+   return 0;
+ }
+ 
+ /* { dg-final { scan-tree-dump-times "if " 1 "optimized"} } */


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