From: dengjianbo <dengjianbo@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, Andreas Schwab <schwab@linux-m68k.org>
Cc: adhemerval.zanella@linaro.org, libc-alpha@sourceware.org,
caiyinyu@loongson.cn, i.swmail@xen0n.name,
joseph_myers@mentor.com, carlos@redhat.com,
xuchenghua@loongson.cn
Subject: Re: [PATCH] LoongArch: Optimize math barriers
Date: Mon, 25 May 2026 09:09:25 +0800 [thread overview]
Message-ID: <d43ff875-59dd-90f5-3b7e-0137a4ab471a@loongson.cn> (raw)
In-Reply-To: <75617e1e-54db-c3cb-1601-7dab304020e7@loongson.cn>
On 5/8/26 5:47 PM, dengjianbo wrote:
>
>
> On 5/8/26 5:29 PM, Xi Ruoyao wrote:
>> On Thu, 2026-05-07 at 17:30 +0800, dengjianbo wrote:
>>> Yes, unnecessary moves can occur if the value is already in a general
>>> reg. For example, when invoking math_opt_barrier with fixed-point
>>> parameters. However, in glibc, these two macros are invoked with
>>> floating-point parameters, and I didn’t find the unnecessary moves
>>> being generated. For other architectures, aarch64 and s390 also do
>>> not include the 'r' constraint.
>>>
>>> For gcc part, to my understanding, when 'fr' is present, GCC selects the
>>> union of FP_REGS and GR_REGS as the destination register class, which is
>>> initialized to GR_REGS. Then compute the cost of choosing different
>>> register classes, choosing GR_REGS incurs no extra cost, while choosing
>>> FP_REGS adds an extra move cost. I am not sure if it's a strategy here.
>>
>> Where does this issue manifest (i.e. in which glibc source file)? I'll
>> try to reduce a test case from that. To me this seems a compiler bug
>> too.
>>>
>>
> One example is the xflow function, compiler generates the unnecessary
> moves for this function, the source file is sysdeps/ieee754/dbl-64
> /math_err.c.
Just a gentle ping on the patch, maybe the below test case can be used
to reproduce this problem.
#define math_opt_barrier(x) \
({ __typeof (x) __x = (x); __asm ("" : "+frm" (__x)); __x; })
double
test (double x)
{
x = math_opt_barrier (x);
return x;
}
prev parent reply other threads:[~2026-05-25 1:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 2:17 Deng Jianbo
2026-05-07 6:46 ` Andreas Schwab
2026-05-07 9:30 ` dengjianbo
2026-05-08 9:29 ` Xi Ruoyao
2026-05-08 9:47 ` dengjianbo
2026-05-25 1:09 ` dengjianbo [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=d43ff875-59dd-90f5-3b7e-0137a4ab471a@loongson.cn \
--to=dengjianbo@loongson.cn \
--cc=adhemerval.zanella@linaro.org \
--cc=caiyinyu@loongson.cn \
--cc=carlos@redhat.com \
--cc=i.swmail@xen0n.name \
--cc=joseph_myers@mentor.com \
--cc=libc-alpha@sourceware.org \
--cc=schwab@linux-m68k.org \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/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).