]> git.ipfire.org Git - thirdparty/gcc.git/commit
[APX NF] Add a pass to convert legacy insn to NF insns
authorHongyu Wang <hongyu.wang@intel.com>
Thu, 18 Apr 2024 08:53:26 +0000 (16:53 +0800)
committerHongyu Wang <hongyu.wang@intel.com>
Mon, 15 Jul 2024 06:50:33 +0000 (14:50 +0800)
commit681ff5ccca153864eb86099eed201838d8d98bc2
tree130ab779d12a465e72a96b07ab203c9974274643
parent60ba989220d9dec07d82009b0dafe684e652577f
[APX NF] Add a pass to convert legacy insn to NF insns

For APX ccmp, current infrastructure will always generate cstore for
the ccmp flag user, like

cmpe    %rcx, %r8
ccmpnel %rax, %rbx
seta %dil
add %rcx, %r9
add     %r9, %rdx
testb   %dil, %dil
je .L2

For such case, the legacy add clobbers FLAGS_REG so there should have
extra cstore to avoid the flag be reset before using it. If the
instructions between flag producer and user are NF insns, the setcc/
test sequence is not required.

Add a pass to convert legacy flag clobber insns to their NF counterpart.
The convertion only happens when
1. APX_NF enabled.
2. For a BB, cstore was find, and there are insns between such cstore
and next explicit set insn to FLAGS_REG (test or cmp).
3. All the insns found should have NF counterpart.

The pass was added after rtl-ifcvt which eliminates some branch when
profitable, which could cause some flag-clobbering insn put between
cstore and jcc.

gcc/ChangeLog:

* config/i386/i386.md (has_nf): New define_attr, add to all
nf related patterns.
* config/i386/i386-features.cc (apx_nf_convert): New function
to convert Non-NF insns to their NF counterparts.
(class pass_apx_nf_convert): New pass class.
(make_pass_apx_nf_convert): New.
* config/i386/i386-passes.def: Add pass_apx_nf_convert after
rtl_ifcvt.
* config/i386/i386-protos.h (make_pass_apx_nf_convert): Declare.

gcc/testsuite/ChangeLog:

* gcc.target/i386/apx-nf-2.c: New test.
gcc/config/i386/i386-features.cc
gcc/config/i386/i386-passes.def
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/apx-nf-2.c [new file with mode: 0644]