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 PR37991, infinite loop in SCCVN


We forget to strip useless conversions after simplifying.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2008-11-02  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/37991
	* tree-ssa-sccvn.h (copy_vuses_from_stmt): Remove.
	* tree-ssa-sccvn.c (copy_vuses_from_stmt): Make static.
	(set_ssa_val_to): Print if the value changed.
	(simplify_binary_expression): Strip useless conversions.

	* gcc.c-torture/compile/pr37991.c: New testcase.

Index: gcc/tree-ssa-sccvn.h
===================================================================
*** gcc/tree-ssa-sccvn.h	(revision 141513)
--- gcc/tree-ssa-sccvn.h	(working copy)
*************** unsigned int get_constant_value_id (tree
*** 196,200 ****
  unsigned int get_or_alloc_constant_value_id (tree);
  bool value_id_constant_p (unsigned int);
  VEC (tree, gc) *shared_vuses_from_stmt (gimple);
- VEC (tree, gc) *copy_vuses_from_stmt (gimple);
  #endif /* TREE_SSA_SCCVN_H  */
--- 196,199 ----
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 141513)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** vuses_to_vec (gimple stmt, VEC (tree, gc
*** 498,504 ****
  /* Copy the VUSE names in STMT into a vector, and return
     the vector.  */
  
! VEC (tree, gc) *
  copy_vuses_from_stmt (gimple stmt)
  {
    VEC (tree, gc) *vuses = NULL;
--- 498,504 ----
  /* Copy the VUSE names in STMT into a vector, and return
     the vector.  */
  
! static VEC (tree, gc) *
  copy_vuses_from_stmt (gimple stmt)
  {
    VEC (tree, gc) *vuses = NULL;
*************** set_ssa_val_to (tree from, tree to)
*** 1579,1585 ****
        print_generic_expr (dump_file, from, 0);
        fprintf (dump_file, " to ");
        print_generic_expr (dump_file, to, 0);
-       fprintf (dump_file, "\n");
      }
  
    currval = SSA_VAL (from);
--- 1579,1584 ----
*************** set_ssa_val_to (tree from, tree to)
*** 1587,1594 ****
--- 1586,1597 ----
    if (currval != to  && !operand_equal_p (currval, to, OEP_PURE_SAME))
      {
        SSA_VAL (from) = to;
+       if (dump_file && (dump_flags & TDF_DETAILS))
+ 	fprintf (dump_file, " (changed)\n");
        return true;
      }
+   if (dump_file && (dump_flags & TDF_DETAILS))
+     fprintf (dump_file, "\n");
    return false;
  }
  
*************** simplify_binary_expression (gimple stmt)
*** 2113,2118 ****
--- 2116,2123 ----
  
    result = fold_binary (gimple_assign_rhs_code (stmt),
  			TREE_TYPE (gimple_get_lhs (stmt)), op0, op1);
+   if (result)
+     STRIP_USELESS_TYPE_CONVERSION (result);
  
    fold_undefer_overflow_warnings (result && valid_gimple_rhs_p (result),
  				  stmt, 0);
Index: gcc/testsuite/gcc.c-torture/compile/pr37991.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr37991.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr37991.c	(revision 0)
***************
*** 0 ****
--- 1,14 ----
+ typedef int Int32;
+ void use_it(int);
+ void FindAndReadSignature(int processedSize)
+ {
+   int numPrevBytes = 1;
+   for (;;)
+     {
+       int numBytesInBuffer = numPrevBytes + processedSize;
+       Int32 numTests = numBytesInBuffer - 1;
+       use_it (numTests);
+       numPrevBytes = numBytesInBuffer - numTests;
+     }
+ }
+ 


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