cpplib: expression parser patch 2

Zack Weinberg zack@wolery.cumb.org
Sun Apr 2 12:40:00 GMT 2000


On Sun, Apr 02, 2000 at 02:55:54PM +0200, Gerald Pfeifer wrote:
> On Sun, 2 Apr 2000, Neil Booth wrote:
> > I've also discovered that gcc optimizes
> > 
> > unsignedp = unsigned1 || unsigned2;
> > 
> > very poorly. Since the "unsigned" variables can only be 0 or 1 (I've
> > checked), my next patch will include the change of these lines to
> > 
> > unsignedp = unsigned1 | unsigned2;
> 
> I think the better approach would be to fix GCC instead of playing
> coding tricks.

I bet the code will mysteriously improve if you compile it with
-mbranch-cost-2.  GCC does know how to optimize (a || b) to (a | b)
but doesn't do it if it thinks branches are dirt cheap.  The i386 port
says branches are dirt cheap for some reason.

Please try that before making this change.

zw


More information about the Gcc-patches mailing list