From a358cee0e585f97851c43aa1e5882a1268407e48 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Tue, 20 Jul 1993 06:23:58 +0000 Subject: [PATCH] (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 --- gcc/expr.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/expr.c b/gcc/expr.c index 965eabc2c76..9ba19e5d3a3 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. -- 2.30.2