On Thu, Apr 17, 2014 at 04:20:06PM +0200, Ondřej Bílka wrote: > On Sat, Apr 12, 2014 at 12:53:45AM +0200, Hannes Frederic Sowa wrote: > > Hi! > > > > On Tue, Oct 29, 2013 at 10:41:56AM +0100, Richard Biener wrote: > > > For a "quick" GCC implementation of the builtins you could expand > > > them to a open-coded sequence during gimplification. But due to > > > the issues pointed out above I'm not sure it is the best interface > > > to support (though now the names are taken). > > > > I played around with gcc internals for the first time today and came > > up with this. As this is my first patch to gcc I am very happy to hear > > feedback. Thanks! > > > Did you looked at resulting assembly for simple expressions?
I had a look but didn't care at all at this point in time. I guess the best way to deal with this in the end is to make the check processor dependent to use overflow/carry flags to check if an overflow/wraparound happend. The addv<mode>4 primitives which came in with asan might be helpful for this. > Also Paul Eggert suggested at another list[1] to implement these with > 128bit arithmetic which gcc can optimize quite well, it uses overflow > flag as check. I thought about that but wasn't sure if 128 bit arithmetic works on all platforms and on freestanding binaries. > Could these builtins use a 128bit arithmetic as well? I guess it would be possible and if it is available on all platforms I could certainly switch to those. > P.S. > > A generated code is affected by generic gcc bug that gcc uses > conditional move instruction even when branch is very unlikely and > jump would be faster. > > [1] https://sourceware.org/ml/libc-alpha/2013-12/msg00084.html Thanks for the pointer! I'll play around and will post a new patch in the not too distant future. ;) Bye, Hannes