[Bug tree-optimization/95862] New: Failure to optimize usage of __builtin_mul_overflow to small __int128-based check
gabravier at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 24 10:51:55 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95862
Bug ID: 95862
Summary: Failure to optimize usage of __builtin_mul_overflow to
small __int128-based check
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
bool f(int32_t a, int32_t b)
{
uint64_t r;
return __builtin_mul_overflow (a, b, &r);
}
This can be optimized to `return ((__uint128_t)(a * (__int128_t)b) >> 64) & 1;`
(idk if this might invoke UB, but rn at least it generates much better code on
x86 than what GCC currently generates for the example I gave). This
transformation is done by LLVM, but not by GCC.
More information about the Gcc-bugs
mailing list