mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-23 07:10:30 +08:00
The following patch generalizes the x ? 1 : 0 -> (int) x optimization to handle also left shifts by constant. During x86_64-linux and i686-linux bootstraps + regtests it triggered in 1514 unique non-LTO -m64 cases (sort -u on log mentioning filename, function name and shift count) and 1866 -m32 cases. Unfortunately, the patch regresses (before the tests have been adjusted): +FAIL: gcc.dg/tree-ssa/ssa-ccp-11.c scan-tree-dump-times optimized "if " 0 +FAIL: gcc.dg/vect/bb-slp-pattern-2.c -flto -ffat-lto-objects scan-tree-dump-times slp1 "optimized: basic block" 1 +FAIL: gcc.dg/vect/bb-slp-pattern-2.c scan-tree-dump-times slp1 "optimized: basic block" 1 and in both cases it actually results in worse code. > > We'd need some optimization that would go through all PHI edges and > > compute if some use of the phi results don't actually compute a constant > > across all the PHI edges - 1 & 0 and 0 & 1 is always 0. > PRE should do this, IMHO only optimizing it at -O2 is fine. > > Similarly, in the slp vectorization test there is: > > a[0] = b[0] ? 1 : 7; > note this, carefully avoiding the already "optimized" b[0] ? 1 : 0 ... > So the option is to put : 7 in the 2, 4 an 8 case as well. The testcase > wasn't added for any real-world case but is artificial I guess for > COND_EXPR handling of invariants. > But yeah, for things like SLP it means we eventually have to > implement reverse transforms for all of this to make the lanes > matching. But that's true anyway for things like x + 1 vs. x + 0 > or x / 3 vs. x / 2 or other simplifications we do. 2020-11-04 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/97690 * tree-ssa-phiopt.c (conditional_replacement): Also optimize cond ? pow2p_cst : 0 as ((type) cond) << cst. * gcc.dg/tree-ssa/phi-opt-22.c: New test. * gcc.dg/tree-ssa/ssa-ccp-11.c: Use -O2 instead of -O1. * gcc.dg/vect/bb-slp-pattern-2.c (foo): Use ? 2 : 7, ? 4 : 7 and ? 8 : 7 instead of ? 2 : 0, ? 4 : 0, ? 8 : 0.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
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.
Description
Languages
C++
31.9%
C
31.3%
Ada
12%
D
6.5%
Go
6.4%
Other
11.5%