Commit a358cee0 by Richard Stallman

(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
parent 04780ee7
...@@ -6898,6 +6898,14 @@ expand_increment (exp, post) ...@@ -6898,6 +6898,14 @@ expand_increment (exp, post)
|| TREE_CODE (exp) == PREDECREMENT_EXPR) || TREE_CODE (exp) == PREDECREMENT_EXPR)
this_optab = sub_optab; 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. */ /* For a preincrement, see if we can do this with a single instruction. */
if (!post) if (!post)
{ {
...@@ -6924,8 +6932,9 @@ expand_increment (exp, post) ...@@ -6924,8 +6932,9 @@ expand_increment (exp, post)
in which case it was stabilized above, or (2) it is an array_ref 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 with constant index in an array in a register, which is
safe to reevaluate. */ safe to reevaluate. */
tree newexp = build ((this_optab == add_optab tree newexp = build (((TREE_CODE (exp) == POSTDECREMENT_EXPR
? PLUS_EXPR : MINUS_EXPR), || TREE_CODE (exp) == PREDECREMENT_EXPR)
? MINUS_EXPR : PLUS_EXPR),
TREE_TYPE (exp), TREE_TYPE (exp),
incremented, incremented,
TREE_OPERAND (exp, 1)); TREE_OPERAND (exp, 1));
...@@ -6933,14 +6942,6 @@ expand_increment (exp, post) ...@@ -6933,14 +6942,6 @@ expand_increment (exp, post)
return post ? op0 : temp; 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) if (post)
{ {
/* We have a true reference to the value in OP0. /* We have a true reference to the value in OP0.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment