[llvm-dev] x.with.overflow semantics question

Nuno Lopes via llvm-dev llvm-dev at lists.llvm.org
Sun May 8 14:14:35 PDT 2016


>> Or do you mean that the result of an add may not even be defined? In that 
>> case would reading it be considered UB in the case where the overflow bit 
>> was set?
>
> Yeah, this is the case I'm worried about: that for example 
> sadd.with.overflow(INT_MAX, 1) might be designed to return { poison, 
> true } instead of giving a useful result in the first element of the 
> struct.

Any argument against that?  I guess that would be the most natural 
definition given the motivation to have these intrinsics (e.g., check if the 
'nmemb * size' operation of calloc overflows; if so return null).

InstCombine will remove these instrinsics if the overflow bit is unused, for 
example. AFAICT, InstCombine never adds nsw/nuw to the replacements.  I 
didn't check GVN.  But I think they should unless there's some reason not 
to.

Nuno 



More information about the llvm-dev mailing list