[PATCH] D74141: [InstCombine] Simplify a umul overflow check to a != 0 && b != 0.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 11:48:53 PST 2020
fhahn added a comment.
In D74141#1864447 <https://reviews.llvm.org/D74141#1864447>, @nikic wrote:
> > Code like this is generated by code using __builtin_mul_overflow with negative integer constants
>
> I'm missing something here, why does clang generate this kind of code? I would have thought that __builtin_mul_overflow maps pretty directly the intrinsic.
I am not entirely sure, but I guess the result type being unsigned forces umul_with_overflow, which treats both operands as unsigned. But if the integer operand is negative, __builtin_mul_overflow has to return true, so Clang needs to add extra checks for that. Clang could try to be a bit better with generating code here, but we would miss out on cases where we can prove that the integer operand is always negative in the middle end.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74141/new/
https://reviews.llvm.org/D74141
More information about the llvm-commits
mailing list