On 10/9/26 12:13 AM, Naveen wrote:
When expanding __builtin_mul_overflow for an unsigned _BitInt result
whose precision is smaller than its machine mode, the widening-multiply
path currently checks overflow at the mode precision and then performs
a second fit check when storing the result.
Use the result type's precision for the overflow check, convert the
product before branching and inform the result-store helper that
overflow has already been checked. The result is still normalized to
the declared precision, while the redundant fit check is omitted.
Regression Tested on X64-64 and aarch64 with no new failures.
gcc/ChangeLog:
PR middle-end/116135
* internal-fn.cc (expand_arith_overflow_result_store): Add
overflow_checked argument. Skip the redundant fit check when
overflow has already been checked but normalize the result.
(expand_addsub_overflow, expand_neg_overflow): Update callers.
(expand_mul_overflow): Check unsigned multiplication overflow at
the result precision for sub-mode precision results.
gcc/testsuite/ChangeLog:
PR middle-end/116135
* gcc.dg/torture/pr116135.c: New test.
* gcc.target/aarch64/pr116135.c: New test.
Signed-off-by: Naveen <[email protected]>
Thanks. No correctness concerns on my side and GCC Sashiko is clean.
OK for the trunk. Sorry for the delays.
jeff