Optimizations on long long multiply/divide on PowerPC32 don't work

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Mon Dec 10 10:59:00 GMT 2001


On Monday 10 December 2001 18:08, Linus Torvalds wrote:
> On Mon, 10 Dec 2001, Franz Sirl wrote:
> > Ah, now that is nice, I always wondered which codepath produced the
> > signeddivide64-by-exactlog2constant to shift conversion on x86, but
> > couldn't find anything in i386.md :-(. I'll try that one on 3.0.3pre and
> > see if the FAT FS compiles again (I wonder if my ashrdi3_nopower pattern
> > will get used then?).
>
> Which part of FAT-FS actually tries to do a signed division?

It's this code fragment:

        inode->i_blocks = ((inode->i_size + inode->i_blksize - 1)
                           & ~(inode->i_blksize - 1)) / 512;

that is in inode.c/fat_read_root() and fat_fill_inode(). It's inode->i_size 
that is of type loff_t here.

> I have a VERY strong suspicion that any filesystem that wants to divide by
> 512 is really just getting a sector number, and the division should not be
> signed in the first place.

It calculates the number of blocks here, so the rounding up might be wanted...

> > Despite the missing GCC optimization, I always wondered if the FAT FS
> > really relies the roundup happening with a signed divide, or if we could
> > simply replace the "/512" with ">>9" without any ill effects? At least I
> > couldn't find anything documented in the code...
>
> It's almost certainly a "loff_t", and we should always have generated
> -EINVAL for negative offsets, so it's pretty much guaranteed to be
> positive modulo any bugs.
>
> Of course, with fatfs, who knows..

Hehe, yeah, exactly :-). Anyway, Richard's patch works fine and gcc3 now is 
able to optimize the divdi3 call away.

Franz.



More information about the Gcc mailing list