This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: portable signed right shift
- To: dewar at gnat dot com, fjh at cs dot mu dot oz dot au
- Subject: Re: portable signed right shift
- From: dewar at gnat dot com
- Date: Fri, 30 Mar 2001 06:08:48 -0500 (EST)
- Cc: gcc at gcc dot gnu dot org
<<But I was wondering if there were any C89 implementations
which didn't always use the machine division instruction;
e.g. perhaps there might be some optimization advantage
to rounding differently in certain cases?.
>>
That's a good point, for example, it IS valid to replace a division in C
(C89) by an arithmetic right shift, even though that gives the "wrong"
result for negative values, and indeed this replacement is a nice
optimization.