This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tuples][patch] Don't create GIMPLE_CONDs that trap
- From: "Rafael Espindola" <espindola at google dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: "Doug Kwan (éæå)" <dougkwan at google dot com>, "Diego Novillo" <dnovillo at google dot com>
- Date: Fri, 2 May 2008 14:16:19 +0100
- Subject: [tuples][patch] Don't create GIMPLE_CONDs that trap
The attached patch fixes the problem we were having with a BB having
more than 2 output edges. It includes a fix for the problem Doug's
observed on tree_could_trap_p.
OK if it bootstraps and passes regression tests.
* tree-eh.c (tree_could_trap_p): Look at the first operand of a
comparison to find if we have a floating point op.
* gimplify.c (gimplify_cond_expr): If a comparison traps, put it in a
GIMPLE_ASSIGN.
Cheers,
--
Rafael Avila de Espindola
Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland
Registered in Dublin, Ireland
Registration Number: 368047
Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c (revision 134885)
+++ gcc/tree-eh.c (working copy)
@@ -2174,7 +2174,10 @@
if (t)
{
- fp_operation = FLOAT_TYPE_P (t);
+ if (COMPARISON_CLASS_P (expr))
+ fp_operation = FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 0)));
+ else
+ fp_operation = FLOAT_TYPE_P (t);
honor_trapv = INTEGRAL_TYPE_P (t) && TYPE_OVERFLOW_TRAPS (t);
}
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c (revision 134885)
+++ gcc/gimplify.c (working copy)
@@ -2908,9 +2908,20 @@
gimple_cond_get_ops_from_tree (COND_EXPR_COND (expr), &pred_code, &arm1,
&arm2);
- gimple_cond = gimple_build_cond (pred_code, arm1, arm2, label_true,
- label_false);
+ if (tree_could_trap_p (COND_EXPR_COND (expr)))
+ {
+ tree cond_var = create_tmp_var (boolean_type_node, NULL);
+ gimple comparison = gimple_build_assign_with_ops (pred_code, cond_var,
+ arm1, arm2);
+ gimplify_seq_add_stmt (pre_p, comparison);
+ gimple_cond = gimple_build_cond (EQ_EXPR, cond_var, boolean_true_node,
+ label_true, label_false);
+ }
+ else
+ gimple_cond = gimple_build_cond (pred_code, arm1, arm2, label_true,
+ label_false);
+
gimplify_seq_add_stmt (pre_p, gimple_cond);
gimplify_seq_add_stmt (pre_p, gimple_build_label (label_true));
have_then_clause_p = gimplify_stmt (&TREE_OPERAND (expr, 1), pre_p);