qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Sandiford <rsandifo@nildram.co.uk>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [4622] Fix for 32-bit MIPS.
Date: Sun, 01 Jun 2008 08:50:46 +0100	[thread overview]
Message-ID: <87y75pzj8p.fsf@firetop.home> (raw)
In-Reply-To: <E1K1sEn-0002rK-2X@cvs.savannah.gnu.org> (Thiemo Seufer's message of "Fri\, 30 May 2008 00\:12\:53 +0000")

Hi Thiemo,

Thanks for applying the patches, and sorry for the fallout on 32-bit
targets from the DIV patch.

Thiemo Seufer <ths@networkno.de> writes:
> @@ -1904,15 +1904,16 @@
>              {
>                  TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
>                  TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
> +                TCGv r_tmp3 = tcg_temp_new(TCG_TYPE_I64);
>  
> -                tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
> -                tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
> -                tcg_gen_div_i64(r_tmp1, cpu_T[0], cpu_T[1]);
> -                tcg_gen_rem_i64(r_tmp2, cpu_T[0], cpu_T[1]);
> -                tcg_gen_ext32s_tl(r_tmp1, r_tmp1);
> -                tcg_gen_ext32s_tl(r_tmp2, r_tmp2);
> -                gen_store_LO(r_tmp1, 0);
> -                gen_store_HI(r_tmp2, 0);
> +                tcg_gen_ext_tl_i64(r_tmp1, cpu_T[0]);
> +                tcg_gen_ext_tl_i64(r_tmp2, cpu_T[1]);
> +                tcg_gen_div_i64(r_tmp3, r_tmp1, r_tmp2);
> +                tcg_gen_rem_i64(r_tmp2, r_tmp1, r_tmp2);
> +                tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp3);
> +                tcg_gen_trunc_i64_tl(cpu_T[1], r_tmp2);
> +                gen_store_LO(cpu_T[0], 0);
> +                gen_store_HI(cpu_T[1], 0);
>              }
>              gen_set_label(l1);
>          }

This isn't quite right for 64-bit targets.  Both pairs of "ext32s"s
really were needed.  The input pair were needed so that we don't trigger
the SIGFPE for unpredictable cases in which the source operands are not
sign-extended.  (Should never happen, of course, but it's a pain if it
crashes the emulator.)  The output pair are needed so that the 32-bit
result is correctly sign-extended.  E.g., with the problem case of
0xffffffff80000000 / -1, the result is now 0x0000000080000000 instead
of 0xffffffff80000000.

In other words, I think we need both the ext32s_tl and the ext_tl_i64/
trunc_i64_tl operations.  Sorry for not picking this up in the original
submission.

Richard

      reply	other threads:[~2008-06-01  7:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-30  0:12 [Qemu-devel] [4622] Fix for 32-bit MIPS Thiemo Seufer
2008-06-01  7:50 ` Richard Sandiford [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y75pzj8p.fsf@firetop.home \
    --to=rsandifo@nildram.co.uk \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).