Go to file
Roger Sayle a56c1641e9 Use PTEST to perform AND in TImode STV of (A & B) != 0 on x86_64.
This x86_64 backend patch allows TImode STV to take advantage of the
fact that the PTEST instruction performs an AND operation.  Previously
PTEST was (mostly) used for comparison against zero, by using the same
operands.  The benefits are demonstrated by the new test case:

__int128 a,b;
int foo()
{
  return (a & b) != 0;
}

Currently with -O2 -msse4 we generate:

        movdqa  a(%rip), %xmm0
        pand    b(%rip), %xmm0
        xorl    %eax, %eax
        ptest   %xmm0, %xmm0
        setne   %al
        ret

with this patch we now generate:

        movdqa  a(%rip), %xmm0
        xorl    %eax, %eax
        ptest   b(%rip), %xmm0
        setne   %al
        ret

Technically, the magic happens using new define_insn_and_split patterns.
Using two patterns allows this transformation to performed independently
of whether TImode STV is run before or after combine.  The one tricky
case is that immediate constant operands of the AND behave slightly
differently between TImode and V1TImode: All V1TImode immediate operands
becomes loads, but for TImode only values that are not hilo_operands
need to be loaded.  Hence the new *testti_doubleword accepts any
general_operand, but internally during split calls force_reg whenever
the second operand is not x86_64_hilo_general_operand.  This required
(benefits from) some tweaks to TImode STV to support CONST_WIDE_INT in
more places, using CONST_SCALAR_INT_P instead of just CONST_INT_P.

2022-08-09  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/i386/i386-features.cc (scalar_chain::convert_compare):
	Create new pseudos only when/if needed.  Add support for TEST,
	i.e. (COMPARE (AND x y) (const_int 0)), using UNSPEC_PTEST.
	When broadcasting V2DImode and V4SImode use new pseudo register.
	(timode_scalar_chain::convert_op): Do nothing if operand is
	already V1TImode.  Avoid generating useless SUBREG conversions,
	i.e. (SUBREG:V1TImode (REG:V1TImode) 0).  Handle CONST_WIDE_INT
	in addition to CONST_INT by using CONST_SCALAR_INT_P.
	(convertible_comparison_p): Use CONST_SCALAR_INT_P to match both
	CONST_WIDE_INT and CONST_INT.  Recognize new *testti_doubleword
	pattern as an STV candidate.
	(timode_scalar_to_vector_candidate_p): Allow CONST_SCALAR_INT_P
	operands in binary logic operations.

	* config/i386/i386.cc (ix86_rtx_costs) <case UNSPEC>: Add costs
	for UNSPEC_PTEST; a PTEST that performs an AND has the same cost
	as regular PTEST, i.e. cost->sse_op.

	* config/i386/i386.md (*testti_doubleword): New pre-reload
	define_insn_and_split that recognizes comparison of TI mode AND
	against zero.
	* config/i386/sse.md (*ptest<mode>_and): New pre-reload
	define_insn_and_split that recognizes UNSPEC_PTEST of identical
	AND operands.

gcc/testsuite/ChangeLog
	* gcc.target/i386/sse4_1-stv-8.c: New test case.
2022-08-09 19:02:44 +01:00
INSTALL
c++tools
config Daily bump. 2022-08-02 00:16:51 +00:00
contrib Daily bump. 2022-08-03 00:16:48 +00:00
fixincludes
gcc Use PTEST to perform AND in TImode STV of (A & B) != 0 on x86_64. 2022-08-09 19:02:44 +01:00
gnattools
gotools
include Daily bump. 2022-07-13 00:16:33 +00:00
intl
libada
libatomic Daily bump. 2022-08-09 00:16:47 +00:00
libbacktrace Daily bump. 2022-07-09 00:16:54 +00:00
libcc1 Daily bump. 2022-06-28 00:16:58 +00:00
libcody Daily bump. 2022-06-04 00:16:27 +00:00
libcpp Daily bump. 2022-08-09 00:16:47 +00:00
libdecnumber Daily bump. 2022-05-21 00:16:32 +00:00
libffi
libgcc Daily bump. 2022-07-19 00:16:32 +00:00
libgfortran Daily bump. 2022-08-02 00:16:51 +00:00
libgo libgo: use SYS_timer_settime32 2022-07-30 10:35:23 -07:00
libgomp Daily bump. 2022-07-30 00:16:30 +00:00
libiberty Daily bump. 2022-07-23 00:16:27 +00:00
libitm Daily bump. 2022-06-03 00:16:40 +00:00
libobjc
liboffloadmic Daily bump. 2022-07-05 00:16:36 +00:00
libphobos Daily bump. 2022-08-04 00:16:49 +00:00
libquadmath
libsanitizer libsanitizer: Cherry-pick 2bfb0fcb51510f22723c8cdfefe from upstream 2022-08-01 06:10:31 +02:00
libssp
libstdc++-v3 Daily bump. 2022-08-09 00:16:47 +00:00
libvtv
lto-plugin Daily bump. 2022-08-02 00:16:51 +00:00
maintainer-scripts Daily bump. 2022-07-29 00:16:21 +00:00
zlib
.dir-locals.el
.gitattributes
.gitignore .gitignore: do not ignore config.h 2022-07-19 17:07:04 +03:00
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2022-08-05 00:16:24 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS Add myself as AutoFDO maintainer 2022-08-04 13:38:28 -07:00
Makefile.def PR bootstrap/106472: Add libgo depends on libbacktrace to Makefile.def 2022-07-31 08:13:30 +01:00
Makefile.in Add TFLAGS to gcc's GCC_FOR_TARGET 2022-06-28 09:41:07 -03:00
Makefile.tpl Add TFLAGS to gcc's GCC_FOR_TARGET 2022-06-28 09:41:07 -03:00
README
ar-lib
compile
config-ml.in
config.guess
config.rpath
config.sub
configure Update configure to check for a recent gnat Ada compiler. 2022-08-01 11:40:50 +01:00
configure.ac [gdb/build] Fix gdbserver build with -fsanitize=thread 2022-06-27 10:52:23 +02:00
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.