[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <p734pmvxt0w.fsf@bingen.suse.de>
Date: 02 May 2007 15:19:11 +0200
From: Andi Kleen <andi@...stfloor.org>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Josh Triplett <josh@...edesktop.org>,
linux-sparse@...r.kernel.org, linux-kernel@...r.kernel.org,
Al Viro <viro@....linux.org.uk>
Subject: Re: sparse -Wptr-subtraction-blows: still needed?
Alan Cox <alan@...rguk.ukuu.org.uk> writes:
>
> Good compilers even in the 1990's would defer the divide and try and
> propogate it out as a multiply the other side for constants, and they'll
> also use shifts when possible.
gcc has an algorithm that tends to generate a near perfect shift/add etc.
code sequence and also knows the obvious x / y ==> x*1/y
However it doesn't do that with -Os, prefering smaller code on x86
(idiv is fairly small compared to the expanded sequences for non power
of two dividends) and kernels are usually compiled with -Os these
days.
We've had a few cases in the past where this showed up as regression
against older kernels that still used -O2.
> Thus they'll turn
>
> (ptr.element - base.element) < NELEM
>
> into
> (ptr.char - base.char) < (constant) [NELEM *sizeof(element) ]
>
>
> at least for constant operations. Dunno if gcc is that clever
It is. However a few more complex transformations I would have liked
in the past are missing -- in particular
x / (cond ? const1 : const2) ==> cond ? (x / const1) : (x / const2)
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists