public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: John Vickers <jvickers@acorn.com>
To: Joern Rennecke <amylaar@cygnus.co.uk>
Cc: egcs@cygnus.com
Subject: Re: Was: Re: Loop optimizer misses simple optimisation?
Date: Thu, 07 May 1998 05:15:00 -0000	[thread overview]
Message-ID: <Marcel-1.26-0507112627-0b0LJLo@ether120.acorn.co.uk> (raw)
In-Reply-To: <199805061729.SAA25923@phal.cygnus.co.uk>

On Wed 06 May, Joern Rennecke wrote:
> > int a, b, c, d;
> > ...
> >   c = b / c;
> >   d = b % c;
> >   
> > becomes:
> > 
> >   c = a / b;
> >   d = a - c * b;  

Ho hum.  Perhaps the transformation above is not necessarily
to the advantage of the user. 

> This would have to depend on the cost of the modulo operation - and if b
> is constant or can be made constant by constant-propagation, this also
> ight make a difference to the cost.

Yes indeed.  We have a lot of ways of skinning the cat,
and we should check the costs, assuming sensible costs
are available ;-).

I should say that I haven't investigated what egcs is doing
in more than a rather cursory way.

I think I was over-generalising without checking my facts -
the targets I'm interested in don't have either SImode divide or divmod.
If the div needs a libcall, it looks like expmed.c::expand_divmod
gives up on trying to optimise the mod.

This is what I was really getting at.


By the way, it seems like there are a few odd tricks which expand_divmod
misses e.g. divisor so big that repeated subtraction is efficient,
or mod when the divisor is (2^n +/-1)*2^m.

John.


      reply	other threads:[~1998-05-07  5:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-28  7:23 Kamil Iskra
1998-04-28 19:14 ` Richard Henderson
1998-04-29 14:48   ` PÃ¥l-Kristian Engstad
1998-04-29 16:08     ` Richard Henderson
1998-04-28 19:49 ` Michael Meissner
1998-04-29 15:21 ` Jim Wilson
1998-05-02  6:13   ` Kamil Iskra
1998-05-03 14:15     ` Jeffrey A Law
1998-05-03 15:32       ` Jim Wilson
1998-05-03 20:10         ` Jeffrey A Law
1998-05-06  7:42           ` Was: " John Vickers
1998-05-06  9:19             ` Jeffrey A Law
1998-05-06 11:36             ` Joern Rennecke
1998-05-07  5:15               ` John Vickers [this message]

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=Marcel-1.26-0507112627-0b0LJLo@ether120.acorn.co.uk \
    --to=jvickers@acorn.com \
    --cc=amylaar@cygnus.co.uk \
    --cc=egcs@cygnus.com \
    /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).