aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2002-12-23 14:43:28 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2002-12-23 14:43:28 +0000
commit0c685f1256349ca34726d19826dad68f3559a6e1 (patch)
tree31685ad42eeb50810729dd451ba7b19f425a95a3 /gcc/tree.c
parent1df7e439e15df663a524df0bbc3aa59617383db0 (diff)
downloadgcc-0c685f1256349ca34726d19826dad68f3559a6e1.zip
gcc-0c685f1256349ca34726d19826dad68f3559a6e1.tar.gz
gcc-0c685f1256349ca34726d19826dad68f3559a6e1.tar.bz2
tree.c (save_expr): Allow either side of a dyadic operand to be constant.
* tree.c (save_expr): Allow either side of a dyadic operand to be constant. * doc/portability.texi (portability): Update portability goals. From-SVN: r60435
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index b2b336b..f2fc48f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1363,12 +1363,23 @@ save_expr (expr)
a constant, it will be more efficient to not make another SAVE_EXPR since
it will allow better simplification and GCSE will be able to merge the
computations if they actualy occur. */
- for (inner = t;
- (TREE_CODE_CLASS (TREE_CODE (inner)) == '1'
- || (TREE_CODE_CLASS (TREE_CODE (inner)) == '2'
- && TREE_CONSTANT (TREE_OPERAND (inner, 1))));
- inner = TREE_OPERAND (inner, 0))
- ;
+ inner = t;
+ while (1)
+ {
+ if (TREE_CODE_CLASS (TREE_CODE (inner)) == '1')
+ inner = TREE_OPERAND (inner, 0);
+ else if (TREE_CODE_CLASS (TREE_CODE (inner)) == '2')
+ {
+ if (TREE_CONSTANT (TREE_OPERAND (inner, 1)))
+ inner = TREE_OPERAND (inner, 0);
+ else if (TREE_CONSTANT (TREE_OPERAND (inner, 0)))
+ inner = TREE_OPERAND (inner, 1);
+ else
+ break;
+ }
+ else
+ break;
+ }
/* If the tree evaluates to a constant, then we don't want to hide that
fact (i.e. this allows further folding, and direct checks for constants).
@@ -1377,7 +1388,8 @@ save_expr (expr)
literal node. */
if (TREE_CONSTANT (inner)
|| (TREE_READONLY (inner) && ! TREE_SIDE_EFFECTS (inner))
- || TREE_CODE (inner) == SAVE_EXPR || TREE_CODE (inner) == ERROR_MARK)
+ || TREE_CODE (inner) == SAVE_EXPR
+ || TREE_CODE (inner) == ERROR_MARK)
return t;
/* If T contains a PLACEHOLDER_EXPR, we must evaluate it each time, since