This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix do_div() for all architectures
- From: Andrea Arcangeli <andrea at suse dot de>
- To: Bernardo Innocenti <bernie at develer dot com>
- Cc: Richard Henderson <rth at twiddle dot net>,Linus Torvalds <torvalds at osdl dot org>, linux-kernel at vger dot kernel dot org,Peter Chubb <peter at chubb dot wattle dot id dot au>,Andrew Morton <akpm at digeo dot com>, Ian Molton <spyro at f2s dot com>,gcc at gcc dot gnu dot org
- Date: Thu, 10 Jul 2003 22:19:39 +0200
- Subject: Re: [PATCH] Fix do_div() for all architectures
- References: <200307060133.15312.bernie@develer.com> <20030710161859.GP16313@dualathlon.random> <20030710163918.GB18697@twiddle.net> <200307102131.45474.bernie@develer.com>
On Thu, Jul 10, 2003 at 09:31:45PM +0200, Bernardo Innocenti wrote:
> On Thursday 10 July 2003 18:39, Richard Henderson wrote:
>
> > On Thu, Jul 10, 2003 at 06:18:59PM +0200, Andrea Arcangeli wrote:
> > > On Thu, Jul 10, 2003 at 08:40:19AM -0700, Richard Henderson wrote:
> > > > On Tue, Jul 08, 2003 at 08:27:26PM +0200, Bernardo Innocenti wrote:
> > > > > +extern uint32_t __div64_32(uint64_t *dividend, uint32_t
> > > > > divisor) __attribute_pure__;
> > > >
> > > > ...
> > > >
> > > > > + __rem = __div64_32(&(n), __base); \
> > > >
> > > > The pure declaration is very incorrect. You're writing to N.
> > >
> > > now pure sounds more reasonable, I wondered how could gcc keep track
> > > of the stuff pointed by the parameters (especially if this stuff
> > > points to other stuff etc.. ;).
>
> The compiler could easily tell what memory can be clobbered by a pointer
> by applying type-based aliasing rules. For example, a function taking a
> "char *" can't clobber memory objects declared as "long bar" or
> "struct foo".
>
> Without type based alias analysis, the compiler is forced to flush
> all registers containing copies of memory objects before function
> call and reloading values from memory afterwards.
the kernel isn't complaint with the alias analysis, that's why it has to
be turned off (-fnostrict-aliasing) or stuff would break.
> Boy, that's ugly! It's too bad C can't do it the Perl way:
>
> (n,rem) = __div64_32(n, base);
or the python way:
n, rem = __div64_32(n, base)
;)
Andrea