This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Temporarily revert gimplify_boolean_expr change
- From: Diego Novillo <dnovillo at redhat dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Jason Merrill <jason at redhat dot com>
- Date: Tue, 26 Aug 2003 18:24:08 -0400
- Subject: [tree-ssa] Temporarily revert gimplify_boolean_expr change
- Organization: Red Hat Canada
Today's bootstrap failed on ppc and ppc64 due to the change to
gimplify_boolean_expr. Jason agreed to remove the patch until he can
figure out what the problem is.
Diego.
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.73
diff -d -u -p -d -c -p -r1.1.2.73 gimplify.c
*** gimplify.c 25 Aug 2003 20:52:18 -0000 1.1.2.73
--- gimplify.c 26 Aug 2003 22:18:34 -0000
*************** static void gimplify_save_expr (tree *,
*** 53,59 ****
static void gimplify_addr_expr (tree *, tree *, tree *);
static void gimplify_self_mod_expr (tree *, tree *, tree *, int);
static void gimplify_cond_expr (tree *, tree *, tree);
! static void gimplify_boolean_expr (tree *);
static void gimplify_return_expr (tree, tree *);
static tree build_addr_expr (tree);
static tree build_addr_expr_with_type (tree, tree);
--- 53,59 ----
static void gimplify_addr_expr (tree *, tree *, tree *);
static void gimplify_self_mod_expr (tree *, tree *, tree *, int);
static void gimplify_cond_expr (tree *, tree *, tree);
! static void gimplify_boolean_expr (tree *, tree *);
static void gimplify_return_expr (tree, tree *);
static tree build_addr_expr (tree);
static tree build_addr_expr_with_type (tree, tree);
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 444,450 ****
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
! gimplify_boolean_expr (expr_p);
break;
case TRUTH_NOT_EXPR:
--- 444,450 ----
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
! gimplify_boolean_expr (expr_p, pre_p);
break;
case TRUTH_NOT_EXPR:
*************** gimplify_modify_expr (tree *expr_p, tree
*** 2027,2047 ****
Expressions of the form 'a && b' are gimplified to:
! a && b ? true : false
! gimplify_cond_expr will do the rest.
PRE_P points to the list where side effects that must happen before
*EXPR_P should be stored. */
static void
! gimplify_boolean_expr (tree *expr_p)
{
! /* Preserve the original type of the expression. */
! tree type = TREE_TYPE (*expr_p);
! *expr_p = build (COND_EXPR, type, *expr_p,
! convert (type, boolean_true_node),
! convert (type, boolean_false_node));
}
--- 2027,2095 ----
Expressions of the form 'a && b' are gimplified to:
! T = a;
! if (T)
! T = b;
! Expressions of the form 'a || b' are gimplified to:
!
! T = a;
! if (!T)
! T = b;
!
! In both cases, the expression is re-written as 'T != 0'.
PRE_P points to the list where side effects that must happen before
+ *EXPR_P should be stored.
+
+ POST_P points to the list where side effects that must happen after
*EXPR_P should be stored. */
static void
! gimplify_boolean_expr (tree *expr_p, tree *pre_p)
{
! tree t, lhs, rhs, if_body, if_cond, if_stmt;
!
! enum tree_code code = TREE_CODE (*expr_p);
!
! #if defined ENABLE_CHECKING
! if (code != TRUTH_ANDIF_EXPR && code != TRUTH_ORIF_EXPR)
! abort ();
! #endif
!
! /* Make this expression right-associative so that gimplification will
! produce nested ifs. */
! *expr_p = right_assocify_expr (*expr_p);
!
! /* First, make sure that our operands have boolean type. */
! lhs = gimple_boolify (TREE_OPERAND (*expr_p, 0));
! rhs = gimple_boolify (TREE_OPERAND (*expr_p, 1));
!
! /* Build 'T = a' */
! t = get_initialized_tmp_var (lhs, pre_p);
!
! /* Build the body for the if() statement that conditionally evaluates the
! RHS of the expression. */
! if_body = build (MODIFY_EXPR, TREE_TYPE (t), t, rhs);
!
! /* Build the condition. */
! if (code == TRUTH_ANDIF_EXPR)
! if_cond = t;
! else
! if_cond = build1 (TRUTH_NOT_EXPR, TREE_TYPE (t), t);
!
! if_stmt = build (COND_EXPR, void_type_node, if_cond, if_body,
! build_empty_stmt ());
! /* Gimplify the IF_STMT and insert it in the PRE_P chain. */
! gimplify_stmt (&if_stmt);
! add_tree (if_stmt, pre_p);
!
! /* If we're not actually looking for a boolean result, convert now. */
! if (TREE_TYPE (t) != TREE_TYPE (*expr_p))
! t = convert (TREE_TYPE (*expr_p), t);
!
! /* Re-write the original expression to use T. */
! *expr_p = t;
}