aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-07-20 06:23:58 +0000
committerRichard Stallman <rms@gnu.org>1993-07-20 06:23:58 +0000
commita358cee0e585f97851c43aa1e5882a1268407e48 (patch)
tree9533cd0e8d0d9b582e0dea97f525ef8a2fc9f36f
parent04780ee7ea605cb7157502cd427fe8555d98d3f5 (diff)
downloadgcc-a358cee0e585f97851c43aa1e5882a1268407e48.zip
gcc-a358cee0e585f97851c43aa1e5882a1268407e48.tar.gz
gcc-a358cee0e585f97851c43aa1e5882a1268407e48.tar.bz2
(expand_increment): Convert constant subtract to add before setting single_insn.
(expand_increment): Convert constant subtract to add before setting single_insn. Compensate for this when choosing the tree code to pass to `build'. From-SVN: r4944
-rw-r--r--gcc/expr.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 965eabc..9ba19e5 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6898,6 +6898,14 @@ expand_increment (exp, post)
|| TREE_CODE (exp) == PREDECREMENT_EXPR)
this_optab = sub_optab;
+ /* Convert decrement by a constant into a negative increment. */
+ if (this_optab == sub_optab
+ && GET_CODE (op1) == CONST_INT)
+ {
+ op1 = GEN_INT (- INTVAL (op1));
+ this_optab = add_optab;
+ }
+
/* For a preincrement, see if we can do this with a single instruction. */
if (!post)
{
@@ -6924,8 +6932,9 @@ expand_increment (exp, post)
in which case it was stabilized above, or (2) it is an array_ref
with constant index in an array in a register, which is
safe to reevaluate. */
- tree newexp = build ((this_optab == add_optab
- ? PLUS_EXPR : MINUS_EXPR),
+ tree newexp = build (((TREE_CODE (exp) == POSTDECREMENT_EXPR
+ || TREE_CODE (exp) == PREDECREMENT_EXPR)
+ ? MINUS_EXPR : PLUS_EXPR),
TREE_TYPE (exp),
incremented,
TREE_OPERAND (exp, 1));
@@ -6933,14 +6942,6 @@ expand_increment (exp, post)
return post ? op0 : temp;
}
- /* Convert decrement by a constant into a negative increment. */
- if (this_optab == sub_optab
- && GET_CODE (op1) == CONST_INT)
- {
- op1 = GEN_INT (- INTVAL (op1));
- this_optab = add_optab;
- }
-
if (post)
{
/* We have a true reference to the value in OP0.