public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105835] [13 Regression] Dead Code Elimination Regression at -O1 (trunk vs. 12.1.0) Date: Sat, 18 Jun 2022 08:10:26 +0000 [thread overview] Message-ID: <bug-105835-4-2sRvUPEvEc@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105835-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105835 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>: https://gcc.gnu.org/g:9991d84d2a84355fd3fc9afc89a963f45991bfa9 commit r13-1162-g9991d84d2a84355fd3fc9afc89a963f45991bfa9 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Sat Jun 18 09:06:20 2022 +0100 PR tree-optimization/105835: Two narrowing patterns for match.pd. This patch resolves PR tree-optimization/105835, which is a code quality (dead code elimination) regression at -O1 triggered/exposed by a recent change to canonicalize X&-Y as X*Y. The new (shorter) form exposes some missed optimization opportunities that can be handled by adding some extra simplifications to match.pd. One transformation is to simplify "(short)(x ? 65535 : 0)" into the equivalent "x ? -1 : 0", or more accurately x ? (short)-1 : (short)0", as INTEGER_CSTs record their type, and integer conversions can be pushed inside COND_EXPRs reducing the number of gimple statements. The other transformation is that (short)(X * 65535), where X is [0,1], into the equivalent (short)X * -1, (or again (short)-1 where tree's INTEGER_CSTs encode their type). This is valid because multiplications where one operand is [0,1] are guaranteed not to overflow, and hence integer conversions can also be pushed inside these multiplications. These narrowing conversion optimizations can be identified by range analyses, such as EVRP, but these are only performed at -O2 and above, which is why this regression is only visible with -O1. 2022-06-18 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog PR tree-optimization/105835 * match.pd (convert (mult zero_one_valued_p@1 INTEGER_CST@2)): Narrow integer multiplication by a zero_one_valued_p operand. (convert (cond @1 INTEGER_CST@2 INTEGER_CST@3)): Push integer conversions inside COND_EXPR where both data operands are integer constants. gcc/testsuite/ChangeLog PR tree-optimization/105835 * gcc.dg/pr105835.c: New test case.
next prev parent reply other threads:[~2022-06-18 8:10 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-03 13:31 [Bug tree-optimization/105835] New: " theodort at inf dot ethz.ch 2022-06-03 15:27 ` [Bug tree-optimization/105835] " roger at nextmovesoftware dot com 2022-06-05 19:05 ` roger at nextmovesoftware dot com 2022-06-13 12:37 ` [Bug tree-optimization/105835] [13 Regression] " rguenth at gcc dot gnu.org 2022-06-18 8:10 ` cvs-commit at gcc dot gnu.org [this message] 2022-06-20 17:10 ` roger at nextmovesoftware dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105835-4-2sRvUPEvEc@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).