[PATCH][tuples] PRE fixes

Richard Guenther rguenther@suse.de
Sat Jul 19 16:35:00 GMT 2008


This is what I committed after re-testing.

Richard.

2008-07-18  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-sccvn.h (get_constant_value_id): Declare.
	(vn_constant_eq_with_type): Make sure an integral type is
	never equal to a non-integral type.
	(vn_hash_constant_with_type): Adjust.
	* tree-ssa-sccvn.c (get_constant_value_id): New function.
	* tree-ssa-pre.c (get_expr_value_id): For newly created
	constant value-ids make sure to add the expression to its
	expression-set.

Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c.orig	2008-07-18 15:40:33.000000000 +0200
--- gcc/tree-ssa-sccvn.c	2008-07-19 13:40:23.000000000 +0200
*************** vn_constant_hash (const void *p1)
*** 328,333 ****
--- 328,351 ----
    return vc1->hashcode;
  }
  
+ /* Lookup a value id for CONSTANT and return it.  If it does not
+    exist returns 0.  */
+ 
+ unsigned int
+ get_constant_value_id (tree constant)
+ {
+   void **slot;
+   struct vn_constant_s vc;
+ 
+   vc.hashcode = vn_hash_constant_with_type (constant);
+   vc.constant = constant;
+   slot = htab_find_slot_with_hash (constant_to_value_id, &vc,
+ 				   vc.hashcode, NO_INSERT);
+   if (slot)
+     return ((vn_constant_t)*slot)->value_id;
+   return 0;
+ }
+ 
  /* Lookup a value id for CONSTANT, and if it does not exist, create a
     new one and return it.  If it does exist, return it.  */
  
Index: gcc/tree-ssa-sccvn.h
===================================================================
*** gcc/tree-ssa-sccvn.h.orig	2008-07-18 15:37:51.000000000 +0200
--- gcc/tree-ssa-sccvn.h	2008-07-19 13:53:20.000000000 +0200
*************** vn_hash_constant_with_type (tree constan
*** 113,118 ****
--- 113,119 ----
  {
    tree type = TREE_TYPE (constant);
    return (iterative_hash_expr (constant, 0)
+ 	  + INTEGRAL_TYPE_P (type)
  	  + (INTEGRAL_TYPE_P (type)
  	     ? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0));
  }
*************** vn_hash_constant_with_type (tree constan
*** 123,134 ****
  static inline bool
  vn_constant_eq_with_type (tree c1, tree c2)
  {
-   tree type1 = TREE_TYPE (c1);
-   tree type2 = TREE_TYPE (c2);
    return (expressions_equal_p (c1, c2)
! 	  && (!INTEGRAL_TYPE_P (type1)
! 	      || ((TYPE_PRECISION (type1) == TYPE_PRECISION (type2)
! 		  && (TYPE_UNSIGNED (type1) == TYPE_UNSIGNED (type2))))));
  }
  
  typedef struct vn_ssa_aux
--- 124,131 ----
  static inline bool
  vn_constant_eq_with_type (tree c1, tree c2)
  {
    return (expressions_equal_p (c1, c2)
! 	  && types_compatible_p (TREE_TYPE (c1), TREE_TYPE (c2)));
  }
  
  typedef struct vn_ssa_aux
*************** hashval_t vn_reference_compute_hash (con
*** 193,198 ****
--- 190,196 ----
  int vn_reference_eq (const void *, const void *);
  unsigned int get_max_value_id (void);
  unsigned int get_next_value_id (void);
+ unsigned int get_constant_value_id (tree);
  unsigned int get_or_alloc_constant_value_id (tree);
  bool value_id_constant_p (unsigned int);
  VEC (tree, gc) *shared_vuses_from_stmt (gimple);
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c.orig	2008-07-18 15:37:51.000000000 +0200
--- gcc/tree-ssa-pre.c	2008-07-19 13:40:23.000000000 +0200
*************** get_expr_value_id (pre_expr expr)
*** 594,600 ****
    switch (expr->kind)
      {
      case CONSTANT:
!       return get_or_alloc_constant_value_id (PRE_EXPR_CONSTANT (expr));
      case NAME:
        return VN_INFO (PRE_EXPR_NAME (expr))->value_id;
      case NARY:
--- 594,609 ----
    switch (expr->kind)
      {
      case CONSTANT:
!       {
! 	unsigned int id;
! 	id = get_constant_value_id (PRE_EXPR_CONSTANT (expr));
! 	if (id == 0)
! 	  {
! 	    id = get_or_alloc_constant_value_id (PRE_EXPR_CONSTANT (expr));
! 	    add_to_value (id, expr);
! 	  }
! 	return id;
!       }
      case NAME:
        return VN_INFO (PRE_EXPR_NAME (expr))->value_id;
      case NARY:



More information about the Gcc-patches mailing list