public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/31261] New: Missed tree optimizations: (8 - (x & 7)) & 7 Date: Mon, 19 Mar 2007 11:05:00 -0000 [thread overview] Message-ID: <bug-31261-87@http.gcc.gnu.org/bugzilla/> (raw) In 4.2 with -O2 -m32 -fomit-frame-pointer on x86_64: unsigned int foo (unsigned int x) { return (8 - (x & 7)) & 7; } results in andl $7, reg; negl reg; andl $7, reg. On 4.3 apparently some RTL optimization catches this, but it is still a missed tree optimization, fold should be able to fold: (cst - (x & cstmask)) & cstmask2 as (cst & cstmask2) + (-x & cstmask2) if x is unsigned or if -INT_MIN wraps to INT_MIN, both cstmask and cstmask2 are constants z^2-1 for some z and (cstmask & cstmask2) == cstmask2. BTW, even for (8 + (x & 7)) & 7 the optimized dump contains: (x & 7) + 8 & 7 for both 4.2/4.3 (no idea why 8 & 7 hasn't been simplified as 0). -- Summary: Missed tree optimizations: (8 - (x & 7)) & 7 Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31261
next reply other threads:[~2007-03-19 11:05 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-03-19 11:05 jakub at gcc dot gnu dot org [this message] 2007-03-19 11:17 ` [Bug tree-optimization/31261] " rguenth at gcc dot gnu dot org 2007-03-19 11:19 ` rguenth at gcc dot gnu dot org 2007-03-21 15:06 ` jakub at gcc dot gnu dot org 2007-03-21 18:28 ` trt at acm dot 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-31261-87@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).