[tcb] Fix various aliasing and verification problems

Devang Patel dpatel@apple.com
Wed Dec 8 00:46:00 GMT 2004


CFG changes in TCB branch exposes this bug in if-conversion. While 
replacing PHI nodes with conditional statements, if-conversion pass 
uses condition stored in predecessor's aux field. However this 
condition is not useful if predecessor is loop header. Following patch 
fixes this.

Here is the test result summary

< Test Run By dpatel on Mon Dec  6 17:51:00 2004
---
 > Test Run By dpatel on Tue Dec  7 14:19:09 2004
31776c31776
< FAIL: gcc.dg/tree-ssa/ifc-20040816-1.c (test for excess errors)
---
 > PASS: gcc.dg/tree-ssa/ifc-20040816-1.c (test for excess errors)
31778c31778
< FAIL: gcc.dg/tree-ssa/ifc-20040816-2.c (test for excess errors)
---
 > PASS: gcc.dg/tree-ssa/ifc-20040816-2.c (test for excess errors)
32081,32082c32081,32082
< FAIL: gcc.dg/vect/vect-none.c (test for excess errors)
< FAIL: gcc.dg/vect/vect-none.c scan-tree-dump-times vectorized  3
---
 > PASS: gcc.dg/vect/vect-none.c (test for excess errors)
 > PASS: gcc.dg/vect/vect-none.c scan-tree-dump-times vectorized  3
32084c32084
< FAIL: gcc.dg/vect/vect-none.c scan-tree-dump-times vectorized 1 loops 
1
---
 > PASS: gcc.dg/vect/vect-none.c scan-tree-dump-times vectorized 1 loops 
1
33093,33094c33093,33094
< # of expected passes          32415
< # of unexpected failures      72
---
 > # of expected passes          32420
 > # of unexpected failures      67

2004-12-07  Devang Patel  <dpatel@apple.com>

         * tree-if-conv.c (find_phi_replacement_condition): New 
parameter, loop.
         While selecting replacement condition pay attention to loop 
header.

OK for tree-cleanup-branch ?

Since this is exposed by changes in the branch, I am not sure if it is 
suitable, at this stage, for mainline or not. I am fine either way.

-
Devang

Index: tree-if-conv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-if-conv.c,v
retrieving revision 2.8.8.4
diff -Idpatel.pbxuser -c -3 -p -r2.8.8.4 tree-if-conv.c
*** tree-if-conv.c      6 Dec 2004 01:03:47 -0000       2.8.8.4
--- tree-if-conv.c      8 Dec 2004 00:38:47 -0000
*************** static void add_to_predicate_list (basic
*** 117,123 ****
   static tree add_to_dst_predicate_list (struct loop * loop, 
basic_block, tree, tree,
                                        block_stmt_iterator *);
   static void clean_predicate_lists (struct loop *loop);
! static basic_block find_phi_replacement_condition (basic_block, tree 
*,
                                                    block_stmt_iterator 
*);
   static void replace_phi_with_cond_modify_expr (tree, tree, 
basic_block,
                                                  block_stmt_iterator *);
--- 117,124 ----
   static tree add_to_dst_predicate_list (struct loop * loop, 
basic_block, tree, tree,
                                        block_stmt_iterator *);
   static void clean_predicate_lists (struct loop *loop);
! static basic_block find_phi_replacement_condition (struct loop *loop,
!                                                  basic_block, tree *,
                                                    block_stmt_iterator 
*);
   static void replace_phi_with_cond_modify_expr (tree, tree, 
basic_block,
                                                  block_stmt_iterator *);
*************** clean_predicate_lists (struct loop *loop
*** 671,677 ****
      whose phi arguments are selected when cond is true.  */

   static basic_block
! find_phi_replacement_condition (basic_block bb, tree *cond,
                                   block_stmt_iterator *bsi)
   {
     edge e;
--- 672,679 ----
      whose phi arguments are selected when cond is true.  */

   static basic_block
! find_phi_replacement_condition (struct loop *loop,
!                               basic_block bb, tree *cond,
                                   block_stmt_iterator *bsi)
   {
     edge e;
*************** find_phi_replacement_condition (basic_bl
*** 696,707 ****
     tmp_cond = p1->aux;
     if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
       {
!       *cond  = p2->aux;
         true_bb = p2;
       }
     else
       {
!       *cond  = p1->aux;
         true_bb = p1;
       }

--- 698,719 ----
     tmp_cond = p1->aux;
     if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)
       {
!       /* If p2 is loop->header than its aux field does not have useful
!        info. Instead use !(cond) where cond is p1's aux field.  */
!       if (p2 == loop->header)
!       *cond = invert_truthvalue (unshare_expr (p1->aux));
!       else
!       *cond  = p2->aux;
         true_bb = p2;
       }
     else
       {
!       /* If p1 is loop->header than its aux field does not have useful
!        info. Instead use !(cond) where cond is p2's aux field.  */
!       if (p1 == loop->header)
!       *cond = invert_truthvalue (unshare_expr (p2->aux));
!       else
!       *cond  = p1->aux;
         true_bb = p1;
       }

*************** process_phi_nodes (struct loop *loop)
*** 822,828 ****
         /* BB has two predecessors. Using predecessor's aux field, set
          appropriate condition for the PHI node replacement.  */
         if (phi)
!       true_bb = find_phi_replacement_condition (bb, &cond, &bsi);

         while (phi)
         {
--- 834,840 ----
         /* BB has two predecessors. Using predecessor's aux field, set
          appropriate condition for the PHI node replacement.  */
         if (phi)
!       true_bb = find_phi_replacement_condition (loop, bb, &cond, 
&bsi);

         while (phi)
         {



More information about the Gcc-patches mailing list