public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ak at muc dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/30747]  New: gcc should optimize x / (cond ? const1 : const2)
Date: Fri, 09 Feb 2007 15:41:00 -0000	[thread overview]
Message-ID: <bug-30747-7834@http.gcc.gnu.org/bugzilla/> (raw)

(seen on other targets too) 

For 

x / (cond ? const1 : const2) 

gcc currently always generates a slow general purpose div. But it would
be much faster to rewrite it to

cond ? (x / const1 : x / const2) 

and then use the optimized sequences for division by constant

In the Linux kernel there are a few cases where this would help.
e.g. it is common in device drivers which manage a ring buffer and the ring
size depends on the hardware revision.

It would be also useful for some other cases where it is not easy
to rewrite the code by hand to the better form.

I made it rtl-optimization, although I presume it could be as well
done on tree level?


-- 
           Summary: gcc should optimize x / (cond ? const1 : const2)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ak at muc dot de
GCC target triplet: x86_64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30747


             reply	other threads:[~2007-02-09 15:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-09 15:41 ak at muc dot de [this message]
2007-02-09 15:41 ` [Bug rtl-optimization/30747] " ak at muc dot de
2007-02-09 16:10 ` pinskia at gcc dot gnu 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-30747-7834@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: link
Be 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).