[llvm-commits] [PATCH] GVN patch for overflow intrinsics

Frits van Bommel fvbommel at gmail.com
Fri Jul 8 02:05:58 PDT 2011


On 8 July 2011 10:04, Lang Hames <lhames at gmail.com> wrote:
> Hi Chris, Frits,
>>
>> > I think that Owen is the best one to handle this.  In addition to
>> > handling the signed versions of these as well, does this correctly handle
>> > the case when the subtract comes first, and the cases when the overflow bit
>> > is actually used?
>>
>> I don't see any issues with the use/non-use of the overflow bit.  For the
>> signed overflow versions, is it only the semantics of the overflow bit that
>> are affected?  Is the value part of the result the same between sadd/uadd?
>
> Yep - use/non-use of the overflow bit should be a non-issue with this patch.
> Regarding the signed intrinsics: I've stayed conservative with this patch. I
> haven't checked the signed intrinsics yet to address Owen's question (do the
> semantics of the value parts change?). I'll try to find time for that
> tomorrow.

The value part of a signed add/sub/mul with overflow should be the
same as that of an unsigned one, and the same as a regular add/sub/mul
instruction in LLVM. This is the reason there are no signed or
unsigned versions of add/sub/mul instructions(nsw/nuw flags
notwithstanding): they would perform the same operation, so there's no
need to distinguish them.


Interesting detail: if calls to both uadd.with.overflow and
sadd.with.overflow, with the same parameters, are in the same basic
block then the code generator (at least, the one for x86-64) will only
create a single 'add', and just read both flags afterward. Nice :).




More information about the llvm-commits mailing list