* [PATCH] LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan
@ 2023-11-23 3:05 Guo Jie
2023-11-23 3:31 ` Xi Ruoyao
2023-11-27 2:54 ` [pushed][PATCH] " chenglulu
0 siblings, 2 replies; 3+ messages in thread
From: Guo Jie @ 2023-11-23 3:05 UTC (permalink / raw)
To: gcc-patches; +Cc: xuchenghua, chenglulu, i, xry111, Guo Jie
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_split_plus_constant):
avoid left shift of negative value -0x8000.
---
gcc/config/loongarch/loongarch.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 33357c670e1..81cd9fa1e7c 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -4249,7 +4249,7 @@ loongarch_split_plus_constant (rtx *op, machine_mode mode)
else if (loongarch_addu16i_imm12_operand_p (v, mode))
a = (v & ~HWIT_UC_0xFFF) + ((v & 0x800) << 1);
else if (mode == DImode && DUAL_ADDU16I_OPERAND (v))
- a = (v > 0 ? 0x7fff : -0x8000) << 16;
+ a = (v > 0 ? 0x7fff0000 : ~0x7fffffff);
else
gcc_unreachable ();
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan
2023-11-23 3:05 [PATCH] LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan Guo Jie
@ 2023-11-23 3:31 ` Xi Ruoyao
2023-11-27 2:54 ` [pushed][PATCH] " chenglulu
1 sibling, 0 replies; 3+ messages in thread
From: Xi Ruoyao @ 2023-11-23 3:31 UTC (permalink / raw)
To: Guo Jie, gcc-patches; +Cc: xuchenghua, chenglulu, i
On Thu, 2023-11-23 at 11:05 +0800, Guo Jie wrote:
> gcc/ChangeLog:
>
> * config/loongarch/loongarch.cc (loongarch_split_plus_constant):
> avoid left shift of negative value -0x8000.
> ---
> gcc/config/loongarch/loongarch.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 33357c670e1..81cd9fa1e7c 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -4249,7 +4249,7 @@ loongarch_split_plus_constant (rtx *op, machine_mode mode)
> else if (loongarch_addu16i_imm12_operand_p (v, mode))
> a = (v & ~HWIT_UC_0xFFF) + ((v & 0x800) << 1);
> else if (mode == DImode && DUAL_ADDU16I_OPERAND (v))
> - a = (v > 0 ? 0x7fff : -0x8000) << 16;
> + a = (v > 0 ? 0x7fff0000 : ~0x7fffffff);
LGTM.
"-0x8000 << 16" is allowed by C++20 [it allows x << 16 as long as x * (1
<< 16) does not overflow], but not C++11.
Unfortunately when I wrote the code I just used the C++20 specification
as a reference... Thanks for the correction.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pushed][PATCH] LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan
2023-11-23 3:05 [PATCH] LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan Guo Jie
2023-11-23 3:31 ` Xi Ruoyao
@ 2023-11-27 2:54 ` chenglulu
1 sibling, 0 replies; 3+ messages in thread
From: chenglulu @ 2023-11-27 2:54 UTC (permalink / raw)
To: Guo Jie, gcc-patches; +Cc: xuchenghua, i, xry111
Pushed to r14-5864.
在 2023/11/23 上午11:05, Guo Jie 写道:
> gcc/ChangeLog:
>
> * config/loongarch/loongarch.cc (loongarch_split_plus_constant):
> avoid left shift of negative value -0x8000.
>
> ---
> gcc/config/loongarch/loongarch.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 33357c670e1..81cd9fa1e7c 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -4249,7 +4249,7 @@ loongarch_split_plus_constant (rtx *op, machine_mode mode)
> else if (loongarch_addu16i_imm12_operand_p (v, mode))
> a = (v & ~HWIT_UC_0xFFF) + ((v & 0x800) << 1);
> else if (mode == DImode && DUAL_ADDU16I_OPERAND (v))
> - a = (v > 0 ? 0x7fff : -0x8000) << 16;
> + a = (v > 0 ? 0x7fff0000 : ~0x7fffffff);
> else
> gcc_unreachable ();
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-27 2:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23 3:05 [PATCH] LoongArch: Fix runtime error in a gcc build with --with-build-config=bootstrap-ubsan Guo Jie
2023-11-23 3:31 ` Xi Ruoyao
2023-11-27 2:54 ` [pushed][PATCH] " chenglulu
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).