public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen
@ 2024-02-08 17:28 hjl.tools at gmail dot com
2024-02-08 17:32 ` [Bug target/113837] " jakub at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-08 17:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
Bug ID: 113837
Summary: Zeroing unused bits in _BitInt can improve codegen
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
CC: crazylht at gmail dot com
Target Milestone: ---
Target: x86-64
I opened this x86-64 psABI issue:
https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues/16
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
@ 2024-02-08 17:32 ` jakub at gcc dot gnu.org
2024-02-08 17:34 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-08 17:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ugh no, please don't.
This is significant ABI change.
First of all, zeroing even for signed _BitInt is very weird, sign extension for
that case is more natural, but when _BitInt doesn't have any unspecified bits,
everything that computes them will need to compute even the extra bits. That
is not the case in the current code.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
2024-02-08 17:32 ` [Bug target/113837] " jakub at gcc dot gnu.org
@ 2024-02-08 17:34 ` jakub at gcc dot gnu.org
2024-02-08 17:35 ` hjl.tools at gmail dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-08 17:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
OT, what is the state of the ia32 _BitInt ABI? I'd really like to enable it in
GCC 14 even for ia32 (and perhaps -mx32 if you care about that case).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
2024-02-08 17:32 ` [Bug target/113837] " jakub at gcc dot gnu.org
2024-02-08 17:34 ` jakub at gcc dot gnu.org
@ 2024-02-08 17:35 ` hjl.tools at gmail dot com
2024-02-08 17:37 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-08 17:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jakub Jelinek from comment #2)
> OT, what is the state of the ia32 _BitInt ABI? I'd really like to enable it
> in GCC 14 even for ia32 (and perhaps -mx32 if you care about that case).
I think we should leave ia32 alone. x32 uses the same psABI as x86-64.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
` (2 preceding siblings ...)
2024-02-08 17:35 ` hjl.tools at gmail dot com
@ 2024-02-08 17:37 ` jakub at gcc dot gnu.org
2024-02-08 17:56 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-08 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #3)
> (In reply to Jakub Jelinek from comment #2)
> > OT, what is the state of the ia32 _BitInt ABI? I'd really like to enable it
> > in GCC 14 even for ia32 (and perhaps -mx32 if you care about that case).
>
> I think we should leave ia32 alone.
You mean never support C23 on it?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
` (3 preceding siblings ...)
2024-02-08 17:37 ` jakub at gcc dot gnu.org
@ 2024-02-08 17:56 ` hjl.tools at gmail dot com
2024-02-08 17:57 ` hjl.tools at gmail dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-08 17:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jakub Jelinek from comment #1)
> Ugh no, please don't.
> This is significant ABI change.
> First of all, zeroing even for signed _BitInt is very weird, sign extension
> for that case is more natural, but when _BitInt doesn't have any unspecified
> bits, everything that computes them will need to compute even the extra
> bits. That is not the case in the current code.
Can we compare zeroing and undefined codegen of unused bits for storing
signed _BitInt?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
` (4 preceding siblings ...)
2024-02-08 17:56 ` hjl.tools at gmail dot com
@ 2024-02-08 17:57 ` hjl.tools at gmail dot com
2024-02-08 18:36 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-08 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jakub Jelinek from comment #4)
> (In reply to H.J. Lu from comment #3)
> > (In reply to Jakub Jelinek from comment #2)
> > > OT, what is the state of the ia32 _BitInt ABI? I'd really like to enable it
> > > in GCC 14 even for ia32 (and perhaps -mx32 if you care about that case).
> >
> > I think we should leave ia32 alone.
>
> You mean never support C23 on it?
Then implement whatever appropriate in GCC and make it the de facto ABI.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
` (5 preceding siblings ...)
2024-02-08 17:57 ` hjl.tools at gmail dot com
@ 2024-02-08 18:36 ` jakub at gcc dot gnu.org
2024-02-08 18:48 ` jakub at gcc dot gnu.org
2024-02-08 20:02 ` hjl.tools at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-08 18:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #5)
> (In reply to Jakub Jelinek from comment #1)
> > Ugh no, please don't.
> > This is significant ABI change.
> > First of all, zeroing even for signed _BitInt is very weird, sign extension
> > for that case is more natural, but when _BitInt doesn't have any unspecified
> > bits, everything that computes them will need to compute even the extra
> > bits. That is not the case in the current code.
>
> Can we compare zeroing and undefined codegen of unused bits for storing
> signed _BitInt?
Not easily, the bitint_info::extended support isn't there yet (as no target
needed it so far). See also the discussions about it on IRC and aarch64
_BitInt support thread (aarch64 wants to have the extra bits unspecified, but
arm 32 extended).
> Then implement whatever appropriate in GCC and make it the de facto ABI.
So what's wrong with
https://gitlab.com/x86-psABIs/i386-ABI/-/issues/5
? Has it been discussed, or is i386-ABI dead?
I'd probably go with 32-bit limbs for _BitInt(65) and higher instead of 64-bit,
but under the hood that is how it will be implemented no matter what the ABI
says,
whether it is 32-bit limbs or 64-bit limbs only affects a) the alignment b) how
much is wasted in case of say _BitInt(65) or _BitInt(129) etc. and what the
sizeof is.
Even if limbs are 64-bit, the question is about alignment, ia32 has 32-bit
alignment for long long and double at least when used inside of structs, so it
would be weird to have different alignment from struct { limb l1, l2; } and
similar.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
` (6 preceding siblings ...)
2024-02-08 18:36 ` jakub at gcc dot gnu.org
@ 2024-02-08 18:48 ` jakub at gcc dot gnu.org
2024-02-08 20:02 ` hjl.tools at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-08 18:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
BTW, I guess we should have some RTL optimization (possibly backend combiner
pattern)
to be able to optimize stuff like
sall $7, y(%rip), %eax
sall $7, %edi
cmpl %eax, %edi
to xorl %edi, y(%rip), %eax; testl $0x1ffffff, %edx
or similar (and similarly without APX).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/113837] Zeroing unused bits in _BitInt can improve codegen
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
` (7 preceding siblings ...)
2024-02-08 18:48 ` jakub at gcc dot gnu.org
@ 2024-02-08 20:02 ` hjl.tools at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-08 20:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113837
--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jakub Jelinek from comment #7)
> (In reply to H.J. Lu from comment #5)
> > (In reply to Jakub Jelinek from comment #1)
> > > Ugh no, please don't.
> > > This is significant ABI change.
> > > First of all, zeroing even for signed _BitInt is very weird, sign extension
> > > for that case is more natural, but when _BitInt doesn't have any unspecified
> > > bits, everything that computes them will need to compute even the extra
> > > bits. That is not the case in the current code.
> >
> > Can we compare zeroing and undefined codegen of unused bits for storing
> > signed _BitInt?
>
> Not easily, the bitint_info::extended support isn't there yet (as no target
> needed it so far). See also the discussions about it on IRC and aarch64
> _BitInt support thread (aarch64 wants to have the extra bits unspecified,
> but arm 32 extended).
>
> > Then implement whatever appropriate in GCC and make it the de facto ABI.
>
> So what's wrong with
> https://gitlab.com/x86-psABIs/i386-ABI/-/issues/5
> ? Has it been discussed, or is i386-ABI dead?
i386 psABI is not actively maintained.
> I'd probably go with 32-bit limbs for _BitInt(65) and higher instead of
> 64-bit,
> but under the hood that is how it will be implemented no matter what the ABI
> says,
> whether it is 32-bit limbs or 64-bit limbs only affects a) the alignment b)
> how much is wasted in case of say _BitInt(65) or _BitInt(129) etc. and what
> the sizeof is.
> Even if limbs are 64-bit, the question is about alignment, ia32 has 32-bit
> alignment for long long and double at least when used inside of structs, so
> it would be weird to have different alignment from struct { limb l1, l2; }
> and similar.
Just implement what is the appropriate in GCC. We will document it.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-02-08 20:02 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08 17:28 [Bug target/113837] New: Zeroing unused bits in _BitInt can improve codegen hjl.tools at gmail dot com
2024-02-08 17:32 ` [Bug target/113837] " jakub at gcc dot gnu.org
2024-02-08 17:34 ` jakub at gcc dot gnu.org
2024-02-08 17:35 ` hjl.tools at gmail dot com
2024-02-08 17:37 ` jakub at gcc dot gnu.org
2024-02-08 17:56 ` hjl.tools at gmail dot com
2024-02-08 17:57 ` hjl.tools at gmail dot com
2024-02-08 18:36 ` jakub at gcc dot gnu.org
2024-02-08 18:48 ` jakub at gcc dot gnu.org
2024-02-08 20:02 ` hjl.tools at gmail dot com
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).