From: Uros Bizjak <ubizjak@gmail.com>
To: Richard Henderson <rth@twiddle.net>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH, alpha]: Fix sysdeps/alpha/remqu.S clobbering $f3 reg
Date: Thu, 24 Jan 2019 09:35:39 +0100 [thread overview]
Message-ID: <CAFULd4aSYnjWM8ovpDmbGCtJfw++6QDpKjEjtBY6AQaFcGGDjQ@mail.gmail.com> (raw)
In-Reply-To: <4b9fbc74-e05e-da71-5e8b-61af289a9f70@twiddle.net>
On Thu, Jan 24, 2019 at 9:23 AM Richard Henderson <rth@twiddle.net> wrote:
>
> On 1/18/19 5:06 AM, Uros Bizjak wrote:
> > Hello!
> >
> > Attached patch fixes sysdeps/alpha/remqu.S clobbering $f3 register via
> > $y_is_neg path. There was missing restore of $f3 before the return
> > from the function.
> >
> > The patch also reorders insns a bit, so it becomes similar as much as
> > possible to divqu.S.
> >
> > Without the patch, math/big testcase from Go-1.11 testsuite (that
> > includes lots of corner cases that exercise remqu) FAIL, with patched
> > function, the testcase PASSes without problems.
>
>
> > +++ b/sysdeps/alpha/remqu.S
> > @@ -59,20 +59,19 @@ __remqu:
> > subq Y, 1, AT
> > stt $f0, 0(sp)
> > and Y, AT, AT
> > + excb
> > + beq AT, $powerof2
> >
> > stt $f1, 8(sp)
> > - excb
>
> Why are you moving the excb above the powerof2 branch?
> The path at powerof2 does not touch fpcr or issue fp insns.
This was meant to unify the flow with the __divqu assembly, which does
the above before calling DIVBYZERO. The idea was that __divqu is used
much more than __remqu, so the later should do the same as the former.
> > @@ -94,12 +93,12 @@ __remqu:
> > mulq AT, Y, AT
> > ldt $f0, 0(sp)
> > ldt $f3, 48(sp)
> > - lda sp, FRAME(sp)
> > cfi_remember_state
> > cfi_restore ($f0)
> > cfi_restore ($f1)
> > cfi_restore ($f3)
> > cfi_def_cfa_offset (0)
> > + lda sp, FRAME(sp)
>
> This change is actively wrong wrt the unwind info.
Again, this will match __divqu assembly. It looks that __divqu needs
to be fixed then.
> > @@ -246,12 +247,16 @@ $y_is_neg:
> > quotient must be either 0 or 1, so the remainder must be X
> > or X-Y, so just compute it directly. */
> > cmpule Y, X, AT
> > + excb
> > + mt_fpcr $f3
> > subq X, Y, RV
> > ldt $f0, 0(sp)
> > + ldt $f3, 48(sp)
> > cmoveq AT, X, RV
> >
> > lda sp, FRAME(sp)
> > cfi_restore ($f0)
> > + cfi_restore ($f3)
> > cfi_def_cfa_offset (0)
> > ret $31, (RA), 1
>
> This appears to be the only change required to fix the bug.
That is true. This part is the problematic part and clobbers $f3.
Should I resend the patch only with this part fixed?
> Can you walk me through why the other changes?
As said above, I was trying to make __remqu like __divqu, but it looks
that __divqu should be fixed in some places.
Thanks,
Uros.
next prev parent reply other threads:[~2019-01-24 8:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-18 13:06 [PATCH, alpha]: Fix sysdeps/alpha/remqu.S clobbering $f3 reg Uros Bizjak
2019-01-20 18:21 ` Uros Bizjak
2019-01-24 8:23 ` Richard Henderson
2019-01-24 8:35 ` Uros Bizjak [this message]
2019-01-24 9:04 ` Richard Henderson
2019-02-27 19:54 ` [PATCH, alpha]: Improve sysdeps/alpha/divqu.S and sysdeps/alpha/remqu.S Uros Bizjak
2019-04-01 9:02 ` Richard Henderson
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFULd4aSYnjWM8ovpDmbGCtJfw++6QDpKjEjtBY6AQaFcGGDjQ@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=libc-alpha@sourceware.org \
--cc=rth@twiddle.net \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).