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]

Re: [lno-branch]: Patch to fix bootstrap problem on darwin


On Mon, Jan 12, 2004 at 05:03:26PM +0200, Dorit Naishlos wrote:
> 
> > This at least gets past the first failure. tree_fold_int_plus can
> > return a NON_LVALUE_EXPR
> 
> thanks! (bootstrapping now)
> 

I have bootstrapped the following patch on i686.  It's the same patch
as Dan's, but it fixes also the other operations.

Can you test it on powerpc?


Index: tree-fold-const.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-fold-const.h,v
retrieving revision 1.1.2.2
diff -c -3 -p -r1.1.2.2 tree-fold-const.h
*** tree-fold-const.h	9 Jan 2004 12:15:53 -0000	1.1.2.2
--- tree-fold-const.h	12 Jan 2004 15:05:34 -0000
*************** static inline tree 
*** 116,135 ****
  tree_fold_int_plus (tree a,
  		    tree b)
  {
    if (TREE_CODE (a) == REAL_CST)
!     return build (PLUS_EXPR, TREE_TYPE (a), a, b);
!   if (TREE_CODE (b) == REAL_CST)
!     return build (PLUS_EXPR, TREE_TYPE (b), a, b);
    else if (TREE_TYPE (a) == TREE_TYPE (b))
!     return fold (build (PLUS_EXPR, TREE_TYPE (a), a, b));
    else
      {
        a = copy_node (a);
        b = copy_node (b);
        TREE_TYPE (a) = integer_type_node;
        TREE_TYPE (b) = integer_type_node;
!       return fold (build (PLUS_EXPR, integer_type_node, a, b));
      }
  }
  
  /* Fold the substraction.  */
--- 116,146 ----
  tree_fold_int_plus (tree a,
  		    tree b)
  {
+   tree res;
+   
    if (TREE_CODE (a) == REAL_CST)
!     res = build (PLUS_EXPR, TREE_TYPE (a), a, b);
!   
!   else if (TREE_CODE (b) == REAL_CST)
!     res = build (PLUS_EXPR, TREE_TYPE (b), a, b);
!   
    else if (TREE_TYPE (a) == TREE_TYPE (b))
!     res = fold (build (PLUS_EXPR, TREE_TYPE (a), a, b));
!   
    else
      {
        a = copy_node (a);
        b = copy_node (b);
        TREE_TYPE (a) = integer_type_node;
        TREE_TYPE (b) = integer_type_node;
!       res = fold (build (PLUS_EXPR, integer_type_node, a, b));
      }
+   
+   if (TREE_CODE (res) == NON_LVALUE_EXPR)
+     return TREE_OPERAND (res, 0);
+   
+   else
+     return res;
  }
  
  /* Fold the substraction.  */
*************** static inline tree 
*** 138,157 ****
  tree_fold_int_minus (tree a,
  		     tree b)
  {
    if (TREE_CODE (a) == REAL_CST)
!     return build (MINUS_EXPR, TREE_TYPE (a), a, b);
!   if (TREE_CODE (b) == REAL_CST)
!     return build (MINUS_EXPR, TREE_TYPE (b), a, b);
    else if (TREE_TYPE (a) == TREE_TYPE (b))
!     return fold (build (MINUS_EXPR, TREE_TYPE (a), a, b));
    else
      {
        a = copy_node (a);
        b = copy_node (b);
        TREE_TYPE (a) = integer_type_node;
        TREE_TYPE (b) = integer_type_node;
!       return fold (build (MINUS_EXPR, integer_type_node, a, b));
      }
  }
  
  /* Fold the multiplication.  */
--- 149,179 ----
  tree_fold_int_minus (tree a,
  		     tree b)
  {
+   tree res;
+   
    if (TREE_CODE (a) == REAL_CST)
!     res = build (MINUS_EXPR, TREE_TYPE (a), a, b);
!   
!   else if (TREE_CODE (b) == REAL_CST)
!     res = build (MINUS_EXPR, TREE_TYPE (b), a, b);
!   
    else if (TREE_TYPE (a) == TREE_TYPE (b))
!     res = fold (build (MINUS_EXPR, TREE_TYPE (a), a, b));
!   
    else
      {
        a = copy_node (a);
        b = copy_node (b);
        TREE_TYPE (a) = integer_type_node;
        TREE_TYPE (b) = integer_type_node;
!       res = fold (build (MINUS_EXPR, integer_type_node, a, b));
      }
+   
+   if (TREE_CODE (res) == NON_LVALUE_EXPR)
+     return TREE_OPERAND (res, 0);
+   
+   else 
+     return res;
  }
  
  /* Fold the multiplication.  */
*************** static inline tree 
*** 160,179 ****
  tree_fold_int_multiply (tree a,
  			tree b)
  {
    if (TREE_CODE (a) == REAL_CST)
!     return build (MULT_EXPR, TREE_TYPE (a), a, b);
!   if (TREE_CODE (b) == REAL_CST)
!     return build (MULT_EXPR, TREE_TYPE (b), a, b);
    else if (TREE_TYPE (a) == TREE_TYPE (b))
!     return fold (build (MULT_EXPR, TREE_TYPE (a), a, b));
    else
      {
        a = copy_node (a);
        b = copy_node (b);
        TREE_TYPE (a) = integer_type_node;
        TREE_TYPE (b) = integer_type_node;
!       return fold (build (MULT_EXPR, integer_type_node, a, b));
      }
  }
  
  /* Division for integer result that rounds the quotient toward zero.  */
--- 182,212 ----
  tree_fold_int_multiply (tree a,
  			tree b)
  {
+   tree res;
+   
    if (TREE_CODE (a) == REAL_CST)
!     res = build (MULT_EXPR, TREE_TYPE (a), a, b);
!   
!   else if (TREE_CODE (b) == REAL_CST)
!     res = build (MULT_EXPR, TREE_TYPE (b), a, b);
!   
    else if (TREE_TYPE (a) == TREE_TYPE (b))
!     res = fold (build (MULT_EXPR, TREE_TYPE (a), a, b));
!   
    else
      {
        a = copy_node (a);
        b = copy_node (b);
        TREE_TYPE (a) = integer_type_node;
        TREE_TYPE (b) = integer_type_node;
!       res = fold (build (MULT_EXPR, integer_type_node, a, b));
      }
+   
+   if (TREE_CODE (res) == NON_LVALUE_EXPR)
+     return TREE_OPERAND (res, 0);
+   
+   else
+     return res;
  }
  
  /* Division for integer result that rounds the quotient toward zero.  */


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