The following patch corrects a mistake with the SSA info updating logic
in eliminate () after my correctness patch for PR69117.  It also handles
one more case optimistically which together fixes the observed regression
in 459.GemsFDTD.

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

Richard.

2016-01-20  Richard Biener  <[email protected]>

        PR tree-optimization/69345
        * tree-ssa-sccvn.h (VN_INFO_RANGE_INFO): New inline function.
        (VN_INFO_PTR_INFO): Likewise.
        * tree-ssa-sccvn.c (set_ssa_val_to): Avoid clearing points-to
        info when it is equal between non-dominating SSA names.
        * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
        Make sure to look at original SSA infos.

Index: gcc/tree-ssa-sccvn.h
===================================================================
*** gcc/tree-ssa-sccvn.h        (revision 232519)
--- gcc/tree-ssa-sccvn.h        (working copy)
*************** vn_valueize (tree name)
*** 243,246 ****
--- 243,266 ----
    return name;
  }
  
+ /* Get at the original range info for NAME.  */
+ 
+ inline range_info_def *
+ VN_INFO_RANGE_INFO (tree name)
+ {
+   return (VN_INFO (name)->info.range_info
+         ? VN_INFO (name)->info.range_info
+         : SSA_NAME_RANGE_INFO (name));
+ }
+ 
+ /* Get at the original pointer info for NAME.  */
+ 
+ inline ptr_info_def *
+ VN_INFO_PTR_INFO (tree name)
+ {
+   return (VN_INFO (name)->info.ptr_info
+         ? VN_INFO (name)->info.ptr_info
+         : SSA_NAME_PTR_INFO (name));
+ }
+ 
  #endif /* TREE_SSA_SCCVN_H  */
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c        (revision 232519)
--- gcc/tree-ssa-sccvn.c        (working copy)
*************** set_ssa_val_to (tree from, tree to)
*** 3092,3098 ****
                  /* Use that from the dominator.  */
                  SSA_NAME_PTR_INFO (to) = SSA_NAME_PTR_INFO (from);
                }
!             else
                {
                  /* Save old info.  */
                  if (! VN_INFO (to)->info.ptr_info)
--- 3092,3102 ----
                  /* Use that from the dominator.  */
                  SSA_NAME_PTR_INFO (to) = SSA_NAME_PTR_INFO (from);
                }
!             else if (! SSA_NAME_PTR_INFO (from)
!                      /* Handle the case of trivially equivalent info.  */
!                      || memcmp (SSA_NAME_PTR_INFO (to),
!                                 SSA_NAME_PTR_INFO (from),
!                                 sizeof (ptr_info_def)) != 0)
                {
                  /* Save old info.  */
                  if (! VN_INFO (to)->info.ptr_info)
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c  (revision 232519)
--- gcc/tree-ssa-pre.c  (working copy)
*************** eliminate_dom_walker::before_dom_childre
*** 4033,4054 ****
            {
              basic_block sprime_b = gimple_bb (SSA_NAME_DEF_STMT (sprime));
              if (POINTER_TYPE_P (TREE_TYPE (lhs))
!                 && SSA_NAME_PTR_INFO (lhs)
!                 && !SSA_NAME_PTR_INFO (sprime))
                {
                  duplicate_ssa_name_ptr_info (sprime,
!                                              SSA_NAME_PTR_INFO (lhs));
                  if (b != sprime_b)
                    mark_ptr_info_alignment_unknown
                        (SSA_NAME_PTR_INFO (sprime));
                }
!             else if (!POINTER_TYPE_P (TREE_TYPE (lhs))
!                      && SSA_NAME_RANGE_INFO (lhs)
!                      && !SSA_NAME_RANGE_INFO (sprime)
                       && b == sprime_b)
                duplicate_ssa_name_range_info (sprime,
                                               SSA_NAME_RANGE_TYPE (lhs),
!                                              SSA_NAME_RANGE_INFO (lhs));
            }
  
          /* Inhibit the use of an inserted PHI on a loop header when
--- 4033,4054 ----
            {
              basic_block sprime_b = gimple_bb (SSA_NAME_DEF_STMT (sprime));
              if (POINTER_TYPE_P (TREE_TYPE (lhs))
!                 && VN_INFO_PTR_INFO (lhs)
!                 && ! VN_INFO_PTR_INFO (sprime))
                {
                  duplicate_ssa_name_ptr_info (sprime,
!                                              VN_INFO_PTR_INFO (lhs));
                  if (b != sprime_b)
                    mark_ptr_info_alignment_unknown
                        (SSA_NAME_PTR_INFO (sprime));
                }
!             else if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
!                      && VN_INFO_RANGE_INFO (lhs)
!                      && ! VN_INFO_RANGE_INFO (sprime)
                       && b == sprime_b)
                duplicate_ssa_name_range_info (sprime,
                                               SSA_NAME_RANGE_TYPE (lhs),
!                                              VN_INFO_RANGE_INFO (lhs));
            }
  
          /* Inhibit the use of an inserted PHI on a loop header when

Reply via email to