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]

[tree-ssa] fix gcc.dg/20020425-1.c


Reduces the max number of function calls in the recursion loop
from 8 to 4, which lets the C else-if testcase pass on Alpha.
It doesn't fix the C++ version though...


r~


        * c-simplify.c (gimplify_if_stmt): Loop for else-if.

Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.4.98
diff -c -p -d -r1.1.4.98 c-simplify.c
*** c-simplify.c	23 Apr 2004 21:14:51 -0000	1.1.4.98
--- c-simplify.c	3 May 2004 17:48:47 -0000
*************** gimplify_do_stmt (tree *stmt_p)
*** 764,772 ****
  static enum gimplify_status
  gimplify_if_stmt (tree *stmt_p)
  {
!   tree stmt = *stmt_p;
!   tree then_ = THEN_CLAUSE (stmt);
!   tree else_ = ELSE_CLAUSE (stmt);
  
    if (!then_)
      then_ = build_empty_stmt ();
--- 764,775 ----
  static enum gimplify_status
  gimplify_if_stmt (tree *stmt_p)
  {
!   tree stmt, then_, else_;
! 
!   stmt = *stmt_p;
!  restart:
!   then_ = THEN_CLAUSE (stmt);
!   else_ = ELSE_CLAUSE (stmt);
  
    if (!then_)
      then_ = build_empty_stmt ();
*************** gimplify_if_stmt (tree *stmt_p)
*** 775,782 ****
  
    stmt = build (COND_EXPR, void_type_node, IF_COND (stmt), then_, else_);
    gimplify_condition (& TREE_OPERAND (stmt, 0));
- 
    *stmt_p = stmt;
    return GS_OK;
  }
  
--- 778,796 ----
  
    stmt = build (COND_EXPR, void_type_node, IF_COND (stmt), then_, else_);
    gimplify_condition (& TREE_OPERAND (stmt, 0));
    *stmt_p = stmt;
+ 
+   /* Handle properly nested if-else chains via iteration instead of
+      mutual recursion between gimplify.c and c-simplify.c.  */
+   annotate_with_locus (stmt, input_location);
+   if (TREE_CODE (else_) == IF_STMT && !TREE_CHAIN (else_))
+     {
+       stmt_p = &COND_EXPR_ELSE (stmt);
+       stmt = else_;
+       prep_stmt (stmt);
+       goto restart;
+     }
+ 
    return GS_OK;
  }
  


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