Commit 859cb4d8 by Geoffrey Keating Committed by Geoffrey Keating

optabs.c (expand_binop): Correctly handle the carry in multiword add/subtract operations.

	* optabs.c (expand_binop): Correctly handle the carry in multiword
	add/subtract operations.

From-SVN: r45210
parent b7a0c86f
2001-08-27 Geoffrey Keating <geoffk@redhat.com>
* optabs.c (expand_binop): Correctly handle the carry in multiword
add/subtract operations.
2001-08-27 Fred Fish <fnf@be.com> 2001-08-27 Fred Fish <fnf@be.com>
* ginclude/stddef.h: Fix typo, __SIZE__TYPE__ should be * ginclude/stddef.h: Fix typo, __SIZE__TYPE__ should be
......
...@@ -1185,7 +1185,6 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods) ...@@ -1185,7 +1185,6 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
&& binoptab->handlers[(int) word_mode].insn_code != CODE_FOR_nothing) && binoptab->handlers[(int) word_mode].insn_code != CODE_FOR_nothing)
{ {
unsigned int i; unsigned int i;
rtx carry_tmp = gen_reg_rtx (word_mode);
optab otheroptab = binoptab == add_optab ? sub_optab : add_optab; optab otheroptab = binoptab == add_optab ? sub_optab : add_optab;
unsigned int nwords = GET_MODE_BITSIZE (mode) / BITS_PER_WORD; unsigned int nwords = GET_MODE_BITSIZE (mode) / BITS_PER_WORD;
rtx carry_in = NULL_RTX, carry_out = NULL_RTX; rtx carry_in = NULL_RTX, carry_out = NULL_RTX;
...@@ -1241,24 +1240,22 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods) ...@@ -1241,24 +1240,22 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if (i > 0) if (i > 0)
{ {
rtx newx;
/* Add/subtract previous carry to main result. */ /* Add/subtract previous carry to main result. */
x = expand_binop (word_mode, newx = expand_binop (word_mode,
normalizep == 1 ? binoptab : otheroptab, normalizep == 1 ? binoptab : otheroptab,
x, carry_in, x, carry_in,
target_piece, 1, next_methods); NULL_RTX, 1, next_methods);
if (x == 0)
break;
else if (target_piece != x)
emit_move_insn (target_piece, x);
if (i + 1 < nwords) if (i + 1 < nwords)
{ {
/* THIS CODE HAS NOT BEEN TESTED. */
/* Get out carry from adding/subtracting carry in. */ /* Get out carry from adding/subtracting carry in. */
rtx carry_tmp = gen_reg_rtx (word_mode);
carry_tmp = emit_store_flag_force (carry_tmp, carry_tmp = emit_store_flag_force (carry_tmp,
binoptab == add_optab (binoptab == add_optab
? LT : GT, ? LT : GT),
x, carry_in, newx, x,
word_mode, 1, normalizep); word_mode, 1, normalizep);
/* Logical-ior the two poss. carry together. */ /* Logical-ior the two poss. carry together. */
...@@ -1268,6 +1265,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods) ...@@ -1268,6 +1265,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
if (carry_out == 0) if (carry_out == 0)
break; break;
} }
emit_move_insn (target_piece, newx);
} }
carry_in = carry_out; carry_in = carry_out;
......
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