From af5bdf6ad76dec71b64412212300e7eb1033c829 Mon Sep 17 00:00:00 2001 From: Waldek Hebisch Date: Fri, 2 Apr 2004 00:30:09 +0200 Subject: [PATCH] * fold-const.c (folda): Preserve types of comparisons. From-SVN: r80327 --- gcc/ChangeLog | 4 ++++ gcc/fold-const.c | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index abe6a3042c4..0d3b02b64fa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2004-04-01 Waldek Hebisch + + * fold-const.c (folda): Preserve types of comparisons. + 2004-04-01 Richard Henderson * toplev.c (backend_init): Move init_optimization_passes call ... diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 772e64e5d2a..3fc6dd27d0b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5366,7 +5366,7 @@ tree_swap_operands_p (tree arg0, tree arg1, bool reorder) The related simplifications include x*1 => x, x*0 => 0, etc., and application of the associative law. NOP_EXPR conversions may be removed freely (as long as we - are careful not to change the C type of the overall expression) + are careful not to change the type of the overall expression). We cannot simplify through a CONVERT_EXPR, FIX_EXPR or FLOAT_EXPR, but we can constant-fold them if they have constant operands. */ @@ -7173,9 +7173,9 @@ fold (tree expr) && integer_zerop (arg1)) { if (code == EQ_EXPR) - return integer_zero_node; + return fold_convert (type, integer_zero_node); else - return integer_one_node; + return fold_convert (type, integer_one_node); } /* If this is an equality comparison of the address of two non-weak, @@ -7196,11 +7196,11 @@ fold (tree expr) && ! DECL_EXTERNAL (TREE_OPERAND (arg1, 0))) { if (code == EQ_EXPR) - return (operand_equal_p (arg0, arg1, 0) - ? integer_one_node : integer_zero_node); + return fold_convert (type, (operand_equal_p (arg0, arg1, 0) + ? integer_one_node : integer_zero_node)); else - return (operand_equal_p (arg0, arg1, 0) - ? integer_zero_node : integer_one_node); + return fold_convert (type, (operand_equal_p (arg0, arg1, 0) + ? integer_zero_node : integer_one_node)); } if (FLOAT_TYPE_P (TREE_TYPE (arg0))) -- 2.30.2