[PATCH] D33391: [DAGCombine] fold (add/uaddo (xor a, -1), 1) -> (sub 0, a)
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 12:02:59 PDT 2017
efriedma added a comment.
Oh, oops, posted the wrong version. Corrected:
#include <stdio.h>
__attribute((noinline)) int f(unsigned a, unsigned *ovf) {
return __builtin_usub_overflow(0, a, ovf);
}
__attribute((noinline)) int f2(unsigned a, unsigned *ovf) {
return __builtin_uadd_overflow(a ^ -1, 1, ovf);
}
int main() {
unsigned sum, ovf;
ovf = f(0, &sum); printf("%u %u\n", sum, ovf);
ovf = f2(0, &sum); printf("%u %u\n", sum, ovf);
ovf = f(1, &sum); printf("%u %u\n", sum, ovf);
ovf = f2(1, &sum); printf("%u %u\n", sum, ovf);
}
(I have no idea why clang generates such weird code for overloaded versions of the intrinsics.)
https://reviews.llvm.org/D33391
More information about the llvm-commits
mailing list