diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1993-12-23 17:14:26 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1993-12-23 17:14:26 -0500 |
commit | ea87523e22cec3e109b6333e6543ad637e06af46 (patch) | |
tree | 3c73c55bd80d0aa62519c6ccc2aee12eb9f93e8c /gcc | |
parent | 5d49bd0cf28aa922b54efce5e1ecfcebc971d457 (diff) | |
download | gcc-ea87523e22cec3e109b6333e6543ad637e06af46.zip gcc-ea87523e22cec3e109b6333e6543ad637e06af46.tar.gz gcc-ea87523e22cec3e109b6333e6543ad637e06af46.tar.bz2 |
(expand_expr, case MINUS_EXPR): When expanding an initializer, use
plus_constant as appropriate.
From-SVN: r6283
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/expr.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -4870,6 +4870,9 @@ expand_expr (exp, target, tmode, modifier) return temp ? temp : gen_rtx (PLUS, mode, op0, op1); case MINUS_EXPR: + /* For initializers, we are allowed to return a MINUS of two + symbolic constants. Here we handle all cases when both operands + are constant. */ /* Handle difference of two symbolic constants, for the sake of an initializer. */ if ((modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER) @@ -4880,7 +4883,17 @@ expand_expr (exp, target, tmode, modifier) VOIDmode, modifier); rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, modifier); - return gen_rtx (MINUS, mode, op0, op1); + + /* If one operand is a CONST_INT, put it last. */ + if (GET_CODE (op0) == CONST_INT) + temp = op0, op0 = op1, op1 = temp; + + /* If the last operand is a CONST_INT, use plus_constant of + the negated constant. Else make the MINUS. */ + if (GET_CODE (op1) == CONST_INT) + return plus_constant (op0, - INTVAL (op1)); + else + return gen_rtx (MINUS, mode, op0, op1); } /* Convert A - const to A + (-const). */ if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST) |