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] Strip useless type conversions after simplifying casts for VN


Catch some more type conversions within FRE and PRE by ignoring useless
type conversions for VN of casts.  (We do the same already for the
non-simplifying path of VN).

Bootstrapped and tested on x86_64-unknown-linux-gnu for all languages + 
Ada.

Ok for mainline?

Thanks,
Richard.

:ADDPATCH PRE:

2006-05-24  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-pre.c (try_combine_conversion): Strip useless
	type conversions after folding.

Index: tree-ssa-pre.c
===================================================================
*** tree-ssa-pre.c	(revision 114040)
--- tree-ssa-pre.c	(working copy)
*************** try_combine_conversion (tree *expr_p)
*** 3330,3341 ****
  
    t = fold_unary (TREE_CODE (expr), TREE_TYPE (expr),
  		  VALUE_HANDLE_EXPR_SET (TREE_OPERAND (expr, 0))->head->expr);
  
    /* Disallow value expressions we have no value number for already, as
       we would miss a leader for it here.  */
!   if (t
!       && !(TREE_CODE (t) == VALUE_HANDLE
! 	   || is_gimple_min_invariant (t)))
      t = vn_lookup (t, NULL);
  
    if (t && t != expr)
--- 3347,3363 ----
  
    t = fold_unary (TREE_CODE (expr), TREE_TYPE (expr),
  		  VALUE_HANDLE_EXPR_SET (TREE_OPERAND (expr, 0))->head->expr);
+   if (!t)
+     return false;
+ 
+   /* Strip useless type conversions, which is safe in the optimizers but
+      not generally in fold.  */
+   STRIP_USELESS_TYPE_CONVERSION (t);
  
    /* Disallow value expressions we have no value number for already, as
       we would miss a leader for it here.  */
!   if (!(TREE_CODE (t) == VALUE_HANDLE
! 	|| is_gimple_min_invariant (t)))
      t = vn_lookup (t, NULL);
  
    if (t && t != expr)


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