[Bug tree-optimization/123864] [13/14/15 Regression] wrong code with __builtin_*_overflow() at -O2 and above since r13-979
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 8 05:19:08 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123864
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:2bf2526ddf1653a4451bb4c23c78477d9b3e1364
commit r15-10892-g2bf2526ddf1653a4451bb4c23c78477d9b3e1364
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jan 30 11:42:41 2026 +0100
match.pd: Fix up __imag__ .MUL_OVERFLOW simplification [PR123864]
The integer_minus_onep case is really meant for multiplication by
-1, not by (unsigned char)0xff or (unsigned short)0xffff or 0xffffffffU
etc.
We've already tested that the first operand is signed (otherwise the
earlier case is used) and also that int_fits_type_p (@1, TREE_TYPE (@0)),
but if @0 is signed and @1 is unsigned all ones with smaller precision
than that, it fits into @0's type, integer_minus_onep will be true
and it still should be handled through the ranges, not as @0 == min.
2026-01-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/123864
* match.pd (__builtin_mul_overflow_p (x, cst, (stype) 0) ->
x > stype_max / cst || x < stype_min / cst): Only check
integer_minus_onep for signed types.
* gcc.c-torture/execute/pr123864.c: New test.
* gcc.dg/torture/pr123864.c: New test.
(cherry picked from commit 238d2fc116cdef31c3d643e71ade0875b5cba110)
More information about the Gcc-bugs
mailing list