Go to file
Uros Bizjak f08995eefb i386: Improve expansion of __builtin_parity
GCC currently hides the shift and xor reduction inside a backend
specific UNSPEC PARITY, making it invisible to the RTL optimizers until
very late during compilation.  It is normally reasonable for the
middle-end to maintain wider mode representations for as long as possible
and split them later, but this only helps if the semantics are visible
at the RTL-level (to combine and other passes), but UNSPECs are black
boxes, so in this case splitting early (during RTL expansion) is a
better strategy.

It turns out that that popcount instruction on modern x86_64 processors
has (almost) made the integer parity flag in the x86 ALU completely
obsolete, especially as POPCOUNT's integer semantics are a much better
fit to RTL.  The one remaining case where these transistors are useful
is where __builtin_parity is immediately tested by a conditional branch,
and therefore the result is wanted in a flags register rather than as
an integer.  This case is captured by two peephole2 optimizations in
the attached patch.

2020-06-07  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog:

	* config/i386/i386.md (paritydi2, paritysi2): Expand reduction
	via shift and xor to an USPEC PARITY matching a parityhi2_cmp.
	(paritydi2_cmp, paritysi2_cmp): Delete these define_insn_and_split.
	(parityhi2, parityqi2): New expanders.
	(parityhi2_cmp): Implement set parity flag with xorb insn.
	(parityqi2_cmp): Implement set parity flag with testb insn.
	New peephole2s to use these insns (UNSPEC PARITY) when appropriate.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/parity-3.c: New test.
	* gcc.target/i386/parity-4.c: Likewise.
	* gcc.target/i386/parity-5.c: Likewise.
	* gcc.target/i386/parity-6.c: Likewise.
	* gcc.target/i386/parity-7.c: Likewise.
	* gcc.target/i386/parity-8.c: Likewise.
	* gcc.target/i386/parity-9.c: Likewise.
2020-06-07 22:09:49 +02:00
INSTALL
config Daily bump. 2020-05-30 00:16:27 +00:00
contrib Daily bump. 2020-06-03 00:16:34 +00:00
fixincludes Allow CONFIG_SHELL to override build-time shell in mkheaders 2020-02-20 22:09:03 -03:00
gcc i386: Improve expansion of __builtin_parity 2020-06-07 22:09:49 +02:00
gnattools
gotools libgo: update to Go1.14beta1 2020-01-21 23:53:22 -08:00
include Do not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin. 2020-04-17 09:22:51 +02:00
intl intl: Unbreak intl build with bison 3 when no regeneration is needed [PR92008] 2020-04-16 11:55:00 +02:00
libada Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libatomic Daily bump. 2020-06-02 00:16:25 +00:00
libbacktrace Daily bump. 2020-05-30 00:16:27 +00:00
libcc1 Daily bump. 2020-05-30 00:16:27 +00:00
libcpp Daily bump. 2020-05-30 00:16:27 +00:00
libdecnumber Daily bump. 2020-05-30 00:16:27 +00:00
libffi libffi/test: Fix compilation for build sysroot 2020-04-25 21:27:14 +01:00
libgcc Daily bump. 2020-06-05 00:16:30 +00:00
libgfortran Daily bump. 2020-06-02 00:16:25 +00:00
libgo libgo: update x/sys/cpu after gccgo support added 2020-05-25 13:43:44 -07:00
libgomp Daily bump. 2020-06-06 00:16:29 +00:00
libhsail-rt Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libiberty Daily bump. 2020-05-30 00:16:27 +00:00
libitm Daily bump. 2020-05-30 00:16:27 +00:00
libobjc Daily bump. 2020-05-30 00:16:27 +00:00
liboffloadmic Add missing ChangeLog entries. 2020-05-05 16:10:13 +02:00
libphobos Daily bump. 2020-05-30 00:16:27 +00:00
libquadmath Daily bump. 2020-05-30 00:16:27 +00:00
libsanitizer Daily bump. 2020-06-03 00:16:34 +00:00
libssp Daily bump. 2020-05-30 00:16:27 +00:00
libstdc++-v3 Daily bump. 2020-06-05 00:16:30 +00:00
libvtv Daily bump. 2020-05-30 00:16:27 +00:00
lto-plugin Daily bump. 2020-05-30 00:16:27 +00:00
maintainer-scripts Daily bump. 2020-05-30 00:16:27 +00:00
zlib Daily bump. 2020-05-30 00:16:27 +00:00
.dir-locals.el
.gitattributes Add *.md diff=md. 2020-01-15 14:29:53 +01:00
.gitignore
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Daily bump. 2020-06-07 00:16:19 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS MAINTAINERS: Add myself as xtensa port maintainer 2020-06-06 01:26:56 -07:00
Makefile.def Merge top-level configury changes from gdb 2020-04-09 06:52:55 -06:00
Makefile.in Merge top-level configury changes from gdb 2020-04-09 06:52:55 -06:00
Makefile.tpl
README
ar-lib
compile
config-ml.in MSP430: Add -fno-exceptions multilib 2019-12-11 19:19:50 +00:00
config.guess
config.rpath
config.sub
configure jit: port libgccjit to Windows 2020-05-28 14:43:58 -04:00
configure.ac jit: port libgccjit to Windows 2020-05-28 14:43:58 -04:00
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh Do not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin. 2020-04-17 09:22:51 +02:00
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.