This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: In C, how to make GCC recognize subtraction with borrow?


On 2017-01-20 18:17:30 +0100, Marc Glisse wrote:
> On Fri, 20 Jan 2017, Vincent Lefevre wrote:
> 
> > In order to do a multiple-precision subtraction on 3 words, one
> > needs to make the compiler recognize subtraction with borrow to
> > get optimal code. For instance, on x86_64, one should get a sub
> > and 2 sbb's. But how can one do this in C (with no inline asm)?
> 
> You said no asm, but not "no builtins", so I'd recommend
> http://clang.llvm.org/docs/LanguageExtensions.html
> https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html
> Note that gcc does not model carry-in, you'll probably have more success
> with clang for that.

But the problem is precisely carry-in.

> I assume there are already relevant bugs in bugzilla, maybe you can
> add your testcase to one (or file a new one if not).

There are bugs, but one is about inline asm and others are on simpler,
more specific cases. So, I've reported:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79173

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]