aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1992-09-29 10:14:19 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1992-09-29 10:14:19 -0400
commit8aecce0a61795105b4bcd0eea2d4d5ad74a54eca (patch)
tree7d3989d4d4b49901b88554e4533b4865484708c1
parent7f11183e26572232a5efd5a3770aa2e1db79dcce (diff)
downloadgcc-8aecce0a61795105b4bcd0eea2d4d5ad74a54eca.zip
gcc-8aecce0a61795105b4bcd0eea2d4d5ad74a54eca.tar.gz
gcc-8aecce0a61795105b4bcd0eea2d4d5ad74a54eca.tar.bz2
(expand_binop): Convert X - C to X + (-C).
From-SVN: r2278
-rw-r--r--gcc/optabs.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/gcc/optabs.c b/gcc/optabs.c
index cabab7f..82f1078 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -297,6 +297,15 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
op1 = force_not_mem (op1);
}
+ /* If subtracting an integer constant, convert this into an addition of
+ the negated constant. */
+
+ if (binoptab == sub_optab && GET_CODE (op1) == CONST_INT)
+ {
+ op1 = negate_rtx (mode, op1);
+ binoptab = add_optab;
+ }
+
/* If we are inside an appropriately-short loop and one operand is an
expensive constant, force it into a register. */
if (CONSTANT_P (op0) && preserve_subexpressions_p ()
@@ -307,19 +316,6 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
&& rtx_cost (op1, binoptab->code) > 2)
op1 = force_reg (shift_op ? word_mode : mode, op1);
-#if 0 /* Turned off because it seems to be a kludgy method. */
- /* If subtracting integer from pointer, and the pointer has a special mode,
- then change it to an add. We use the add insn of Pmode for combining
- integers with pointers, and the sub insn to subtract two pointers. */
-
- if (binoptab == sub_optab
- && GET_MODE (op0) == Pmode && GET_MODE (op1) != Pmode)
- {
- op1 = negate_rtx (GET_MODE(op1), op1);
- binoptab = add_optab;
- }
-#endif /* 0 */
-
/* Record where to delete back to if we backtrack. */
last = get_last_insn ();