@@ -545,45 +545,74 @@ static bitmap_obstack grand_bitmap_obstack;
545545/* A three tuple {e, pred, v} used to cache phi translations in the
546546 phi_translate_table. */
547547
548- typedef struct expr_pred_trans_d : free_ptr_hash < expr_pred_trans_d >
548+ typedef struct expr_pred_trans_d : public typed_noop_remove < expr_pred_trans_d >
549549{
550- /* The expression. */
551- pre_expr e ;
550+ typedef expr_pred_trans_d value_type ;
551+ typedef expr_pred_trans_d compare_type ;
552552
553- /* The predecessor block along which we translated the expression. */
554- basic_block pred ;
553+ /* The expression ID . */
554+ unsigned e ;
555555
556- /* The value that resulted from the translation . */
557- pre_expr v ;
556+ /* The predecessor block index along which we translated the expression . */
557+ int pred ;
558558
559- /* The hashcode for the expression, pred pair. This is cached for
560- speed reasons. */
561- hashval_t hashcode ;
559+ /* The value expression ID that resulted from the translation. */
560+ unsigned v ;
562561
563562 /* hash_table support. */
564- static inline hashval_t hash (const expr_pred_trans_d * );
565- static inline int equal (const expr_pred_trans_d * , const expr_pred_trans_d * );
563+ static inline void mark_empty (expr_pred_trans_d & );
564+ static inline bool is_empty (const expr_pred_trans_d & );
565+ static inline void mark_deleted (expr_pred_trans_d & );
566+ static inline bool is_deleted (const expr_pred_trans_d & );
567+ static const bool empty_zero_p = true;
568+ static inline hashval_t hash (const expr_pred_trans_d & );
569+ static inline int equal (const expr_pred_trans_d & , const expr_pred_trans_d & );
566570} * expr_pred_trans_t ;
567571typedef const struct expr_pred_trans_d * const_expr_pred_trans_t ;
568572
573+ inline bool
574+ expr_pred_trans_d ::is_empty (const expr_pred_trans_d & e )
575+ {
576+ return e .e == 0 ;
577+ }
578+
579+ inline bool
580+ expr_pred_trans_d ::is_deleted (const expr_pred_trans_d & e )
581+ {
582+ return e .e == -1u ;
583+ }
584+
585+ inline void
586+ expr_pred_trans_d ::mark_empty (expr_pred_trans_d & e )
587+ {
588+ e .e = 0 ;
589+ }
590+
591+ inline void
592+ expr_pred_trans_d ::mark_deleted (expr_pred_trans_d & e )
593+ {
594+ e .e = -1u ;
595+ }
596+
569597inline hashval_t
570- expr_pred_trans_d ::hash (const expr_pred_trans_d * e )
598+ expr_pred_trans_d ::hash (const expr_pred_trans_d & e )
571599{
572- return e -> hashcode ;
600+ return iterative_hash_hashval_t ( e . e , e . pred ) ;
573601}
574602
575603inline int
576- expr_pred_trans_d ::equal (const expr_pred_trans_d * ve1 ,
577- const expr_pred_trans_d * ve2 )
604+ expr_pred_trans_d ::equal (const expr_pred_trans_d & ve1 ,
605+ const expr_pred_trans_d & ve2 )
578606{
579- basic_block b1 = ve1 -> pred ;
580- basic_block b2 = ve2 -> pred ;
607+ int b1 = ve1 . pred ;
608+ int b2 = ve2 . pred ;
581609
582610 /* If they are not translations for the same basic block, they can't
583611 be equal. */
584612 if (b1 != b2 )
585613 return false;
586- return pre_expr_d ::equal (ve1 -> e , ve2 -> e );
614+
615+ return ve1 .e == ve2 .e ;
587616}
588617
589618/* The phi_translate_table caches phi translations for a given
@@ -596,24 +625,22 @@ static hash_table<expr_pred_trans_d> *phi_translate_table;
596625static inline bool
597626phi_trans_add (expr_pred_trans_t * entry , pre_expr e , basic_block pred )
598627{
599- expr_pred_trans_t * slot ;
628+ expr_pred_trans_t slot ;
600629 expr_pred_trans_d tem ;
601- hashval_t hash = iterative_hash_hashval_t (pre_expr_d ::hash (e ),
602- pred -> index );
603- tem .e = e ;
604- tem .pred = pred ;
605- tem .hashcode = hash ;
606- slot = phi_translate_table -> find_slot_with_hash (& tem , hash , INSERT );
607- if (* slot )
630+ unsigned id = get_expression_id (e );
631+ hashval_t hash = iterative_hash_hashval_t (id , pred -> index );
632+ tem .e = id ;
633+ tem .pred = pred -> index ;
634+ slot = phi_translate_table -> find_slot_with_hash (tem , hash , INSERT );
635+ if (slot -> e )
608636 {
609- * entry = * slot ;
637+ * entry = slot ;
610638 return true;
611639 }
612640
613- * entry = * slot = XNEW (struct expr_pred_trans_d );
614- (* entry )-> e = e ;
615- (* entry )-> pred = pred ;
616- (* entry )-> hashcode = hash ;
641+ * entry = slot ;
642+ slot -> e = id ;
643+ slot -> pred = pred -> index ;
617644 return false;
618645}
619646
@@ -1675,6 +1702,7 @@ phi_translate (bitmap_set_t dest, pre_expr expr,
16751702 bitmap_set_t set1 , bitmap_set_t set2 , edge e )
16761703{
16771704 expr_pred_trans_t slot = NULL ;
1705+ size_t slot_size = 0 ;
16781706 pre_expr phitrans ;
16791707
16801708 if (!expr )
@@ -1691,10 +1719,11 @@ phi_translate (bitmap_set_t dest, pre_expr expr,
16911719 if (expr -> kind != NAME )
16921720 {
16931721 if (phi_trans_add (& slot , expr , e -> src ))
1694- return slot -> v ;
1722+ return slot -> v == 0 ? NULL : expression_for_id ( slot -> v ) ;
16951723 /* Store NULL for the value we want to return in the case of
16961724 recursing. */
1697- slot -> v = NULL ;
1725+ slot -> v = 0 ;
1726+ slot_size = phi_translate_table -> size ();
16981727 }
16991728
17001729 /* Translate. */
@@ -1705,12 +1734,15 @@ phi_translate (bitmap_set_t dest, pre_expr expr,
17051734
17061735 if (slot )
17071736 {
1737+ /* Check for reallocation. */
1738+ if (phi_translate_table -> size () != slot_size )
1739+ phi_trans_add (& slot , expr , e -> src );
17081740 if (phitrans )
1709- slot -> v = phitrans ;
1741+ slot -> v = get_expression_id ( phitrans ) ;
17101742 else
17111743 /* Remove failed translations again, they cause insert
17121744 iteration to not pick up new opportunities reliably. */
1713- phi_translate_table -> remove_elt_with_hash (slot , slot -> hashcode );
1745+ phi_translate_table -> clear_slot (slot );
17141746 }
17151747
17161748 return phitrans ;
0 commit comments