public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Deng Jianbo <dengjianbo@loongson.cn>
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: Thu, 07 May 2026 08:46:53 +0200	[thread overview]
Message-ID: <87jytf90o2.fsf@igel.home> (raw)
In-Reply-To: <20260507021740.16572-1-dengjianbo@loongson.cn> (Deng Jianbo's message of "Thu, 7 May 2026 10:17:40 +0800")

On Mai 07 2026, Deng Jianbo wrote:

> The constraints 'frm' used in math_opt_barrier and math_force_eval cause
> GCC choose fixed-point registers with lower costs in some cases, because
> in LoongArch ira_reg_class_subunion[FP_REGS][GR_REGS] is initialized to
> GR_REGS, extra move costs will be added when choosing FP_REGS. This
> results in unnecessary instructions to move values between FP_REGS and
> GR_REGS.

It looks like a bug in GCC (wrong cost calculations) if it generates
unnecessary moves when it has more choices.

> Most of cases in GLIBC math barriers related macros are invoked with
> floating-point type paramters, this patch removes "r" constraints,
> allowing GCC to keep values in floating-point registers and avoid the
> extra moves.

It does not *allow* that, it *forces* gcc to use an fp reg (or memory).
What if the value is in a general reg in the first place, wouldn't that
result in unnecessary moves?

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2026-05-07  6:47 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 [this message]
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

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=87jytf90o2.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=carlos@redhat.com \
    --cc=dengjianbo@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=joseph_myers@mentor.com \
    --cc=libc-alpha@sourceware.org \
    --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).