public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113609] New: EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF.
@ 2024-01-26 3:17 liuhongt at gcc dot gnu.org
2024-01-26 3:37 ` [Bug target/113609] " liuhongt at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-01-26 3:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113609
Bug ID: 113609
Summary: EQ/NE comparison between avx512 kmask and -1 can be
optimized with kxortest with checking CF.
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: liuhongt at gcc dot gnu.org
Target Milestone: ---
It's from PR113576, there's code like
35 kmovb %k0, %edx
36 cmpb $-1, %dl
37 jne .L21
The original codegen is buggy, but still exposed a optimization issue.
Compare 8/16/32/64-bit kmask to -1 and check equal or not can be optimized with
kortest by check CF.
KORTESTW ¶
TMP[15:0] := DEST[15:0] BITWISE OR SRC[15:0]
IF(TMP[15:0]=0)
THEN ZF := 1
ELSE ZF := 0
FI;
IF(TMP[15:0]=FFFFh)
THEN CF := 1
ELSE CF := 0
FI;
KORTESTB ¶
TMP[7:0] := DEST[7:0] BITWISE OR SRC[7:0]
IF(TMP[7:0]=0)
THEN ZF := 1
ELSE ZF := 0
FI;
IF(TMP[7:0]==FFh)
THEN CF := 1
ELSE CF := 0
FI;
KORTESTQ ¶
TMP[63:0] := DEST[63:0] BITWISE OR SRC[63:0]
IF(TMP[63:0]=0)
THEN ZF := 1
ELSE ZF := 0
FI;
IF(TMP[63:0]==FFFFFFFF_FFFFFFFFh)
THEN CF := 1
ELSE CF := 0
FI;
KORTESTD ¶
TMP[31:0] := DEST[31:0] BITWISE OR SRC[31:0]
IF(TMP[31:0]=0)
THEN ZF := 1
ELSE ZF := 0
FI;
IF(TMP[31:0]=FFFFFFFFh)
THEN CF := 1
ELSE CF := 0
FI;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/113609] EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF.
2024-01-26 3:17 [Bug target/113609] New: EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF liuhongt at gcc dot gnu.org
@ 2024-01-26 3:37 ` liuhongt at gcc dot gnu.org
2024-01-26 7:58 ` ubizjak at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-01-26 3:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113609
--- Comment #1 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
Since they're different modes, CCZ for cmp, but CCS for kortest, it could be
diffcult to optimize it in RA stage by adding alternatives(like we did for
compared to 0). So the easy way could be adding peephole to hanlde that.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/113609] EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF.
2024-01-26 3:17 [Bug target/113609] New: EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF liuhongt at gcc dot gnu.org
2024-01-26 3:37 ` [Bug target/113609] " liuhongt at gcc dot gnu.org
@ 2024-01-26 7:58 ` ubizjak at gmail dot com
2024-06-03 5:44 ` cvs-commit at gcc dot gnu.org
2024-06-03 6:50 ` liuhongt at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2024-01-26 7:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113609
--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Hongtao Liu from comment #1)
> Since they're different modes, CCZ for cmp, but CCS for kortest, it could be
> diffcult to optimize it in RA stage by adding alternatives(like we did for
> compared to 0). So the easy way could be adding peephole to hanlde that.
You can use pre-reload split for this. Please see for example how *jcc_bt<mode>
and *bt<mode>_setcqi provide compound operation (constructed from CCZmode
compare) that is later split to CCCmode operation. You will have to provide jcc
and setcc patterns to fully handle mode change.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/113609] EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF.
2024-01-26 3:17 [Bug target/113609] New: EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF liuhongt at gcc dot gnu.org
2024-01-26 3:37 ` [Bug target/113609] " liuhongt at gcc dot gnu.org
2024-01-26 7:58 ` ubizjak at gmail dot com
@ 2024-06-03 5:44 ` cvs-commit at gcc dot gnu.org
2024-06-03 6:50 ` liuhongt at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-03 5:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113609
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hu <hulin@gcc.gnu.org>:
https://gcc.gnu.org/g:bf7745f887c765e06f2e75508f263debb60aeb2e
commit r15-974-gbf7745f887c765e06f2e75508f263debb60aeb2e
Author: Hu, Lin1 <lin1.hu@intel.com>
Date: Thu May 9 09:29:07 2024 +0800
i386: Optimize EQ/NE comparison between avx512 kmask and -1.
Acheive EQ/NE comparison between avx512 kmask and -1 by using kxortest
with checking CF.
gcc/ChangeLog:
PR target/113609
* config/i386/sse.md
(*kortest_cmp<mode>_setcc): New define_insn_and_split.
(*kortest_cmp<mode>_jcc): Ditto.
gcc/testsuite/ChangeLog:
PR target/113609
* gcc.target/i386/pr113609-1.c: New test.
* gcc.target/i386/pr113609-2.c: Ditto.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/113609] EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF.
2024-01-26 3:17 [Bug target/113609] New: EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF liuhongt at gcc dot gnu.org
` (2 preceding siblings ...)
2024-06-03 5:44 ` cvs-commit at gcc dot gnu.org
@ 2024-06-03 6:50 ` liuhongt at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-06-03 6:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113609
Hongtao Liu <liuhongt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
Fixed in GCC15
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-03 6:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 3:17 [Bug target/113609] New: EQ/NE comparison between avx512 kmask and -1 can be optimized with kxortest with checking CF liuhongt at gcc dot gnu.org
2024-01-26 3:37 ` [Bug target/113609] " liuhongt at gcc dot gnu.org
2024-01-26 7:58 ` ubizjak at gmail dot com
2024-06-03 5:44 ` cvs-commit at gcc dot gnu.org
2024-06-03 6:50 ` liuhongt at gcc dot gnu.org
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).