]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: eliminate redundant operands of VPTERNLOG
authorYan Simonaytes <simonaytes.yan@ispras.ru>
Tue, 25 Jul 2023 17:43:19 +0000 (20:43 +0300)
committerAlexander Monakov <amonakov@ispras.ru>
Fri, 4 Aug 2023 16:43:51 +0000 (19:43 +0300)
commit567d06bb357a39ece865cef67ada44124f227e45
treede7d733db250bddfdf529de6c2678652cae0fefc
parentc572f09a751cbd365e2285b30527de5ab9025972
i386: eliminate redundant operands of VPTERNLOG

As mentioned in PR 110202, GCC may be presented with input where control
word of the VPTERNLOG intrinsic implies that some of its operands do not
affect the result.  In that case, we can eliminate redundant operands
of the instruction by substituting any other operand in their place.
This removes false dependencies.

For instance, instead of (252 = 0xfc = _MM_TERNLOG_A | _MM_TERNLOG_B)

vpternlogq $252, %zmm2, %zmm1, %zmm0

emit

vpternlogq $252, %zmm0, %zmm1, %zmm0

When VPTERNLOG is invariant w.r.t first and second operands, and the
third operand is memory, load memory into the output operand first, i.e.
instead of (85 = 0x55 = ~_MM_TERNLOG_C)

vpternlogq $85, (%rdi), %zmm1, %zmm0

emit

vmovdqa64 (%rdi), %zmm0
vpternlogq $85, %zmm0, %zmm0, %zmm0

gcc/ChangeLog:

PR target/110202
* config/i386/i386-protos.h
(vpternlog_redundant_operand_mask): Declare.
(substitute_vpternlog_operands): Declare.
* config/i386/i386.cc
(vpternlog_redundant_operand_mask): New helper.
(substitute_vpternlog_operands): New function.  Use them...
* config/i386/sse.md: ... here in new VPTERNLOG define_splits.

gcc/testsuite/ChangeLog:

PR target/110202
* gcc.target/i386/invariant-ternlog-1.c: New test.
* gcc.target/i386/invariant-ternlog-2.c: New test.
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.cc
gcc/config/i386/sse.md
gcc/testsuite/gcc.target/i386/invariant-ternlog-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/invariant-ternlog-2.c [new file with mode: 0644]