From 6a97296a060b9e053ae598076ffa14c41a5b6f39 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Wed, 22 Sep 2004 11:40:12 +0000 Subject: [PATCH] fold-const.c (fold): Avoid non INTEGER_TYPEs when widening operands in an integer comparison. * fold-const.c (fold): Avoid non INTEGER_TYPEs when widening operands in an integer comparison. * tree-cfg.c (find_taken_edge): Call fold() to determine whether the predicate is known. From-SVN: r87855 --- gcc/ChangeLog | 7 +++++++ gcc/fold-const.c | 1 + gcc/tree-cfg.c | 19 +++---------------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7eff6e8940a..115f39bd7a4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-09-22 Diego Novillo + + * fold-const.c (fold): Avoid non INTEGER_TYPEs when widening + operands in an integer comparison. + * tree-cfg.c (find_taken_edge): Call fold() to determine + whether the predicate is known. + 2004-09-22 Kelley Cook * aclocal.m4: Import AM_PROG_CC_C_O and AM_AUX_DIR_EXPAND. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 25c84a45914..c762fada3fe 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8290,6 +8290,7 @@ fold (tree expr) && (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0 && (TREE_TYPE (t1) == TREE_TYPE (tem) || (TREE_CODE (t1) == INTEGER_CST + && TREE_CODE (TREE_TYPE (tem)) == INTEGER_TYPE && int_fits_type_p (t1, TREE_TYPE (tem))))) return fold (build2 (code, type, tem, fold_convert (TREE_TYPE (tem), t1))); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 37b57102f63..51c4bed9048 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2001,22 +2001,9 @@ find_taken_edge (basic_block bb, tree val) gcc_assert (is_ctrl_stmt (stmt)); /* If VAL is a predicate of the form N RELOP N, where N is an - SSA_NAME, we can always determine its truth value (except when - doing floating point comparisons that may involve NaNs). */ - if (val - && COMPARISON_CLASS_P (val) - && TREE_OPERAND (val, 0) == TREE_OPERAND (val, 1) - && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME - && (TREE_CODE (TREE_TYPE (TREE_OPERAND (val, 0))) != REAL_TYPE - || !HONOR_NANS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (val, 0)))))) - { - enum tree_code code = TREE_CODE (val); - - if (code == EQ_EXPR || code == LE_EXPR || code == GE_EXPR) - val = boolean_true_node; - else if (code == LT_EXPR || code == GT_EXPR || code == NE_EXPR) - val = boolean_false_node; - } + SSA_NAME, we can usually determine its truth value. */ + if (val && COMPARISON_CLASS_P (val)) + val = fold (val); /* If VAL is not a constant, we can't determine which edge might be taken. */ -- 2.30.2