public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/86693] inefficient atomic_fetch_xor
[not found] <bug-86693-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-25 11:34 ` pinskia at gcc dot gnu.org
2021-12-27 2:18 ` crazylht at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-25 11:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86693
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/86693] inefficient atomic_fetch_xor
[not found] <bug-86693-4@http.gcc.gnu.org/bugzilla/>
2021-12-25 11:34 ` [Bug target/86693] inefficient atomic_fetch_xor pinskia at gcc dot gnu.org
@ 2021-12-27 2:18 ` crazylht at gmail dot com
2021-12-27 3:03 ` hjl.tools at gmail dot com
2021-12-28 6:23 ` crazylht at gmail dot com
3 siblings, 0 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2021-12-27 2:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86693
--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
Change testcase a little bit, gcc now can generate lock btc
void func1();
void func(unsigned long *counter)
{
if (__atomic_fetch_xor(counter, 1, __ATOMIC_ACQ_REL) & 1) {
func1();
}
}
func(unsigned long*):
lock btc QWORD PTR [rdi], 0
jc .L4
ret
.L4:
jmp func1()
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/86693] inefficient atomic_fetch_xor
[not found] <bug-86693-4@http.gcc.gnu.org/bugzilla/>
2021-12-25 11:34 ` [Bug target/86693] inefficient atomic_fetch_xor pinskia at gcc dot gnu.org
2021-12-27 2:18 ` crazylht at gmail dot com
@ 2021-12-27 3:03 ` hjl.tools at gmail dot com
2021-12-28 6:23 ` crazylht at gmail dot com
3 siblings, 0 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2021-12-27 3:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86693
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Hongtao.liu from comment #4)
> Change testcase a little bit, gcc now can generate lock btc
>
>
> void func1();
>
> void func(unsigned long *counter)
> {
> if (__atomic_fetch_xor(counter, 1, __ATOMIC_ACQ_REL) & 1) {
> func1();
> }
> }
>
>
> func(unsigned long*):
> lock btc QWORD PTR [rdi], 0
> jc .L4
> ret
> .L4:
> jmp func1()
We should rewrite the original test to the canonical form, similar to r12-5102.
Hongtao, can you do that?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/86693] inefficient atomic_fetch_xor
[not found] <bug-86693-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2021-12-27 3:03 ` hjl.tools at gmail dot com
@ 2021-12-28 6:23 ` crazylht at gmail dot com
3 siblings, 0 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2021-12-28 6:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86693
--- Comment #6 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to H.J. Lu from comment #5)
> (In reply to Hongtao.liu from comment #4)
> > Change testcase a little bit, gcc now can generate lock btc
> >
> >
> > void func1();
> >
> > void func(unsigned long *counter)
> > {
> > if (__atomic_fetch_xor(counter, 1, __ATOMIC_ACQ_REL) & 1) {
> > func1();
> > }
> > }
> >
> >
> > func(unsigned long*):
> > lock btc QWORD PTR [rdi], 0
> > jc .L4
> > ret
> > .L4:
> > jmp func1()
>
> We should rewrite the original test to the canonical form, similar to
> r12-5102.
> Hongtao, can you do that?
The orginal testcase is not equal to btc, __atomic_fetch_xor(counter, 1,
__ATOMIC_ACQ_REL) == 1 require other bits of *counter is 0. And as #c1 said, we
don't have instructions to keep the old or new value of xor or ior in a
register.
I can't find a way to optimize off the exchangeloop.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-28 6:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-86693-4@http.gcc.gnu.org/bugzilla/>
2021-12-25 11:34 ` [Bug target/86693] inefficient atomic_fetch_xor pinskia at gcc dot gnu.org
2021-12-27 2:18 ` crazylht at gmail dot com
2021-12-27 3:03 ` hjl.tools at gmail dot com
2021-12-28 6:23 ` crazylht 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).