This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, i386]: Fix target/35944, [4.3, 4.4 regression] wrong result for MOD with kind=10 for some array argument values
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 16 Apr 2008 18:02:17 +0200
- Subject: [PATCH, i386]: Fix target/35944, [4.3, 4.4 regression] wrong result for MOD with kind=10 for some array argument values
Hello!
This patch copies operand[1] and operand[2] into temporary registers
before they enter fmod loop. It looks that current fmodxf3
implementation is somehow confusing to gcc, so it mix input and output
registers.
Attached patch implements fmodxf3 (and remainderxf3) in the same way as
...df3 and ...sf3 patterns are implemented. This fixes fortran testcase
in PR target/35944.
2008-04-16 Uros Bizjak <ubizjak@gmail.com>
PR target/35944
* config/i386/i386.md (fmodxf3): Copy operand 1 and operand 2 into
temporary registers. Change operand predicate to general_operand.
(remainderxf3): Ditto.
Patch was bootstrapped and regression tested on i686-pc-linux-gnu. Patch
is committed to mainline, will be committed to 4.3 in a couple of days.
BTW: It would be nice for if someone can create and commit a testcase
from the fortran example in the PR.
Uros.
Index: i386.md
===================================================================
--- i386.md (revision 134344)
+++ i386.md (working copy)
@@ -16434,28 +16434,24 @@
(define_expand "fmodxf3"
[(use (match_operand:XF 0 "register_operand" ""))
- (use (match_operand:XF 1 "register_operand" ""))
- (use (match_operand:XF 2 "register_operand" ""))]
+ (use (match_operand:XF 1 "general_operand" ""))
+ (use (match_operand:XF 2 "general_operand" ""))]
"TARGET_USE_FANCY_MATH_387"
{
rtx label = gen_label_rtx ();
- rtx op2;
+ rtx op1 = gen_reg_rtx (XFmode);
+ rtx op2 = gen_reg_rtx (XFmode);
- if (rtx_equal_p (operands[1], operands[2]))
- {
- op2 = gen_reg_rtx (XFmode);
- emit_move_insn (op2, operands[2]);
- }
- else
- op2 = operands[2];
+ emit_move_insn (op1, operands[1]);
+ emit_move_insn (op2, operands[2]);
emit_label (label);
- emit_insn (gen_fpremxf4_i387 (operands[1], op2, operands[1], op2));
+ emit_insn (gen_fpremxf4_i387 (op1, op2, op1, op2));
ix86_emit_fp_unordered_jump (label);
LABEL_NUSES (label) = 1;
- emit_move_insn (operands[0], operands[1]);
+ emit_move_insn (operands[0], op1);
DONE;
})
@@ -16506,28 +16502,24 @@
(define_expand "remainderxf3"
[(use (match_operand:XF 0 "register_operand" ""))
- (use (match_operand:XF 1 "register_operand" ""))
- (use (match_operand:XF 2 "register_operand" ""))]
+ (use (match_operand:XF 1 "general_operand" ""))
+ (use (match_operand:XF 2 "general_operand" ""))]
"TARGET_USE_FANCY_MATH_387"
{
rtx label = gen_label_rtx ();
- rtx op2;
+ rtx op1 = gen_reg_rtx (XFmode);
+ rtx op2 = gen_reg_rtx (XFmode);
- if (rtx_equal_p (operands[1], operands[2]))
- {
- op2 = gen_reg_rtx (XFmode);
- emit_move_insn (op2, operands[2]);
- }
- else
- op2 = operands[2];
+ emit_move_insn (op1, operands[1]);
+ emit_move_insn (op2, operands[2]);
emit_label (label);
- emit_insn (gen_fprem1xf4_i387 (operands[1], op2, operands[1], op2));
+ emit_insn (gen_fprem1xf4_i387 (op1, op2, op1, op2));
ix86_emit_fp_unordered_jump (label);
LABEL_NUSES (label) = 1;
- emit_move_insn (operands[0], operands[1]);
+ emit_move_insn (operands[0], op1);
DONE;
})