[PATCH] D51929: [DAGCombiner] use UADDO to optimize saturated unsigned add

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 21 16:15:45 PDT 2018


spatel added a comment.

In https://reviews.llvm.org/D51929#1242413, @lebedev.ri wrote:

> For completeness sake, i was *thinking* of something like: https://godbolt.org/z/uoShW6


Yes - that's the kind of codegen we're trying for - see the x86 test for unsigned_sat_constant_i32_using_cmp_notval().
But I think you have overflow and carry mixed up:
https://stackoverflow.com/questions/19301498/carry-flag-auxiliary-flag-and-overflow-flag-in-assembly

Ignoring all of the missing canonicalizations for the moment, this patch will give us the same output as gcc:
https://godbolt.org/z/dYnXhf

(cmovnc is the same as cmovae)


https://reviews.llvm.org/D51929





More information about the llvm-commits mailing list