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 middle-end/98865] Missed transform of (a >> 63) * b Date: Fri, 27 May 2022 08:02:38 +0000 [thread overview] Message-ID: <bug-98865-4-vh5pURBcQO@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-98865-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98865 --- Comment #8 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:8fb94fc6097c0a934aac0d89c9c5e2038da67655 commit r13-793-g8fb94fc6097c0a934aac0d89c9c5e2038da67655 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Fri May 27 08:57:46 2022 +0100 Canonicalize X&-Y as X*Y in match.pd when Y is [0,1]. "For every pessimization, there's an equal and opposite optimization". In the review of my original patch for PR middle-end/98865, Richard Biener pointed out that match.pd shouldn't be transforming X*Y into X&-Y as the former is considered cheaper by tree-ssa's cost model (operator count). A corollary of this is that we should instead be transforming X&-Y into the cheaper X*Y as a preferred canonical form (especially as RTL expansion now intelligently selects the appropriate implementation based on the target's costs). With this patch we now generate identical code for: int foo(int x, int y) { return -(x&1) & y; } int bar(int x, int y) { return (x&1) * y; } specifically on x86_64-pc-linux-gnu both use and/neg/and with -O2, but both use and/mul with -Os. One minor wrinkle/improvement is that this patch includes three additional optimizations (that account for the change in canonical form) to continue to optimize PR92834 and PR94786. 2022-05-27 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * match.pd (match_zero_one_valued_p): New predicate. (mult @0 @1): Use zero_one_valued_p for optimization to the expression "bit_and @0 @1". (bit_and (negate zero_one_valued_p@0) @1): Optimize to MULT_EXPR. (plus @0 (mult (minus @1 @0) zero_one_valued_p@2)): New transform. (minus @0 (mult (minus @0 @1) zero_one_valued_p@2)): Likewise. (bit_xor @0 (mult (bit_xor @0 @1) zero_one_valued_p@2)): Likewise. Remove three redundant transforms obsoleted by the three above. gcc/testsuite/ChangeLog * gcc.dg/pr98865.c: New test case.
next prev parent reply other threads:[~2022-05-27 8:02 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-28 13:38 [Bug middle-end/98865] New: " rguenth at gcc dot gnu.org 2021-01-28 13:40 ` [Bug middle-end/98865] " rguenth at gcc dot gnu.org 2021-01-28 14:26 ` jakub at gcc dot gnu.org 2021-03-07 2:46 ` pinskia at gcc dot gnu.org 2021-07-20 22:19 ` pinskia at gcc dot gnu.org 2021-09-22 18:19 ` cvs-commit at gcc dot gnu.org 2022-01-11 11:19 ` rguenth at gcc dot gnu.org 2022-05-18 15:24 ` cvs-commit at gcc dot gnu.org 2022-05-19 16:55 ` cvs-commit at gcc dot gnu.org 2022-05-27 8:02 ` cvs-commit at gcc dot gnu.org [this message] 2022-05-28 9:18 ` 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-98865-4-vh5pURBcQO@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).