public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Lulu Cheng <chenglulu@loongson.cn>, gcc-patches@gcc.gnu.org
Cc: WANG Xuerui <i@xen0n.name>, Chenghua Xu <xuchenghua@loongson.cn>
Subject: Re: [GCC14 PATCH] LoongArch: Optimize additions with immediates
Date: Tue, 04 Apr 2023 16:00:45 +0800	[thread overview]
Message-ID: <62922ce154f7f52147341b905d3c844cd50e6682.camel@xry111.site> (raw)
In-Reply-To: <39b42972-9a0f-3ada-b9b9-2c53da946217@loongson.cn>

On Tue, 2023-04-04 at 11:01 +0800, Lulu Cheng wrote:

/* snip */

> > +unsigned long f10 (unsigned long x) { return x - 0x80000000l * 2; }
> > +unsigned long f11 (unsigned long x) { return x - 0x80000000l * 2; }
>  These two test cases are duplicates.

/* snip */

> 
> > +unsigned int g10 (unsigned int x) { return x - 0x80000000l * 2; }
> > +unsigned int g11 (unsigned int x) { return x - 0x80000000l * 2; }
> Ditto.

I'll fix them in V2.

> I found that adding this log test case gcc.target/loongarch/stack-check-cfa-1.c and gcc.target/loongarch/stack-check-cfa-2.c test failed.
> Although the test fails, the generated assembly code is better, and there is no problem with the logic of the assembly code. I haven't checked the reason for this yet.

Looks like the change hides PR109035 (like -fpie) for some reason. (But
I still don't understand the root cause of PR109035 anyway.)

f_test:
.LFB0 = .
	.cfi_startproc
	lu12i.w	$r14,65536>>12			# 0x10000
	sub.d	$r3,$r3,$r14
	st.d	$r0,$r3,0
	sub.d	$r3,$r3,$r14
	st.d	$r0,$r3,0
	.cfi_def_cfa_offset 131072
	lu12i.w	$r13,131072>>12			#
0x20000
	or	$r12,$r3,$r0
	ldx.b	$r4,$r12,$r4
	add.d	$r3,$r3,$r13
	.cfi_def_cfa_offset 0
	jr	$r1
	.cfi_endproc

Technically there should be "addu16i.d $r3,$r3,-1" in the prologue and
"addu16i.d $r3,$r3,2" in the epilogue, so we can avoid using r14/r13.
I'll try modifying loongarch_expand_{pro,epi}logue for this.


-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-04-04  8:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02 14:00 Xi Ruoyao
2023-04-04  3:01 ` Lulu Cheng
2023-04-04  8:00   ` Xi Ruoyao [this message]
2023-04-04  8:40     ` Xi Ruoyao
2023-04-04  9:15       ` Lulu Cheng

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=62922ce154f7f52147341b905d3c844cd50e6682.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --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).