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] Minor fix to tail recursion code



The tree tail recursion code was creating PHI nodes with arguments which
had mis-matched types.  In the right circumstances this can cause a abort
when expanding into RTL (c-torture/compile/20040317-2.c)

This patch tightens the code in question to avoid tail recursion in that
case.  In the future an interested party could arrange to create a
temporary, do the necessary conversions, etc.

	* tree-tailcall.c (find_tail_calls): Tighten test for tail recursion.

Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-tailcall.c,v
retrieving revision 1.1.2.22
diff -c -p -r1.1.2.22 tree-tailcall.c
*** tree-tailcall.c	16 Mar 2004 22:31:56 -0000	1.1.2.22
--- tree-tailcall.c	17 Mar 2004 21:16:23 -0000
*************** find_tail_calls (basic_block bb, struct 
*** 407,414 ****
  	   param && args;
  	   param = TREE_CHAIN (param), args = TREE_CHAIN (args))
  	if (param != TREE_VALUE (args)
! 	    /* Make sure there are no problems with copying.  */
! 	    && !is_gimple_reg_type (TREE_TYPE (param)))
  	  break;
        if (!args && !param)
  	tail_recursion = true;
--- 407,419 ----
  	   param && args;
  	   param = TREE_CHAIN (param), args = TREE_CHAIN (args))
  	if (param != TREE_VALUE (args)
! 	    /* Make sure there are no problems with copying.  Note we must
! 	       have a copyable type and the two arguments must have reasonably
! 	       equivalent types.  The latter requirement could be relaxed if
! 	       we emitted a suitable type conversion statement.  */
! 	    && (!is_gimple_reg_type (TREE_TYPE (param))
! 		|| (TYPE_MAIN_VARIANT (TREE_TYPE (param)) 
! 		    != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (args))))))
  	  break;
        if (!args && !param)
  	tail_recursion = true;




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