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 rtl-optimization/55278] [10/11/12/13 Regression] Botan performance regressions, other compilers generate better code than gcc Date: Wed, 15 Jun 2022 07:32:29 +0000 [thread overview] Message-ID: <bug-55278-4-jDTN724puh@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55278-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55278 --- Comment #30 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:acb1e6f43dc2bbedd1248ea61c7ab537a11fe59b commit r13-1100-gacb1e6f43dc2bbedd1248ea61c7ab537a11fe59b Author: Roger Sayle <roger@nextmovesoftware.com> Date: Wed Jun 15 09:31:13 2022 +0200 Fold truncations of left shifts in match.pd Whilst investigating PR 55278, I noticed that the tree-ssa optimizers aren't eliminating the promotions of shifts to "int" as inserted by the c-family front-ends, instead leaving this simplification to be left to the RTL optimizers. This patch allows match.pd to do this itself earlier, narrowing (T)(X << C) to (T)X << C when the constant C is known to be valid for the (narrower) type T. Hence for this simple test case: short foo(short x) { return x << 5; } the .optimized dump currently looks like: short int foo (short int x) { int _1; int _2; short int _4; <bb 2> [local count: 1073741824]: _1 = (int) x_3(D); _2 = _1 << 5; _4 = (short int) _2; return _4; } but with this patch, now becomes: short int foo (short int x) { short int _2; <bb 2> [local count: 1073741824]: _2 = x_1(D) << 5; return _2; } This is always reasonable as RTL expansion knows how to use widening optabs if it makes sense at the RTL level to perform this shift in a wider mode. Of course, there's often a catch. The above simplification not only reduces the number of statements in gimple, but also allows further optimizations, for example including the perception of rotate idioms and bswap16. Alas, optimizing things earlier than anticipated requires several testsuite changes [though all these tests have been confirmed to generate identical assembly code on x86_64]. The only significant change is that the vectorization pass wouldn't previously lower rotations of signed integer types. Hence this patch includes a refinement to tree-vect-patterns to allow signed types, by using the equivalent unsigned shifts. 2022-06-15 Roger Sayle <roger@nextmovesoftware.com> Richard Biener <rguenther@suse.de> gcc/ChangeLog * match.pd (convert (lshift @1 INTEGER_CST@2)): Narrow integer left shifts by a constant when the result is truncated, and the shift constant is well-defined. * tree-vect-patterns.cc (vect_recog_rotate_pattern): Add support for rotations of signed integer types, by lowering using unsigned vector shifts. gcc/testsuite/ChangeLog * gcc.dg/fold-convlshift-4.c: New test case. * gcc.dg/optimize-bswaphi-1.c: Update found bswap count. * gcc.dg/tree-ssa/pr61839_3.c: Shift is now optimized before VRP. * gcc.dg/vect/vect-over-widen-1-big-array.c: Remove obsolete tests. * gcc.dg/vect/vect-over-widen-1.c: Likewise. * gcc.dg/vect/vect-over-widen-3-big-array.c: Likewise. * gcc.dg/vect/vect-over-widen-3.c: Likewise. * gcc.dg/vect/vect-over-widen-4-big-array.c: Likewise. * gcc.dg/vect/vect-over-widen-4.c: Likewise.
next prev parent reply other threads:[~2022-06-15 7:32 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-11 23:54 [Bug rtl-optimization/55278] New: Botan performance regressions apparently due to LRA hubicka at gcc dot gnu.org 2013-03-23 19:38 ` [Bug rtl-optimization/55278] [4.8 Regression] " steven at gcc dot gnu.org 2013-03-25 10:21 ` [Bug rtl-optimization/55278] [4.8/4.9 " rguenth at gcc dot gnu.org 2013-03-25 11:03 ` hubicka at gcc dot gnu.org 2013-05-07 22:31 ` mpolacek at gcc dot gnu.org 2013-05-07 22:31 ` mpolacek at gcc dot gnu.org 2013-05-07 22:34 ` jakub at gcc dot gnu.org 2013-05-07 22:48 ` glisse at gcc dot gnu.org 2013-05-08 6:58 ` jakub at gcc dot gnu.org 2013-05-09 13:59 ` jakub at gcc dot gnu.org 2013-05-09 20:35 ` vmakarov at redhat dot com 2013-05-12 17:36 ` [Bug rtl-optimization/55278] [4.8/4.9 Regression] Botan performance regressions, other compilers generate better code than gcc ubizjak at gmail dot com 2013-05-31 11:01 ` jakub at gcc dot gnu.org 2013-10-16 9:49 ` jakub at gcc dot gnu.org 2014-05-22 9:06 ` [Bug rtl-optimization/55278] [4.8/4.9/4.10 " rguenth at gcc dot gnu.org 2014-12-19 13:28 ` [Bug rtl-optimization/55278] [4.8/4.9/5 " jakub at gcc dot gnu.org 2015-06-23 8:21 ` [Bug rtl-optimization/55278] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org 2015-06-26 19:57 ` [Bug rtl-optimization/55278] [4.9/5/6 " jakub at gcc dot gnu.org 2015-06-26 20:29 ` jakub at gcc dot gnu.org 2021-05-14 9:46 ` [Bug rtl-optimization/55278] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:05 ` rguenth at gcc dot gnu.org 2021-07-08 18:00 ` ubizjak at gmail dot com 2022-05-27 9:34 ` [Bug rtl-optimization/55278] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-15 7:32 ` cvs-commit at gcc dot gnu.org [this message] 2022-06-28 10:30 ` jakub at gcc dot gnu.org 2023-03-16 0:05 ` pinskia at gcc dot gnu.org 2023-07-07 10:29 ` [Bug rtl-optimization/55278] [11/12/13/14 " rguenth at gcc dot gnu.org
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-55278-4-jDTN724puh@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).