https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116135

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Naveen H.S <[email protected]>:

https://gcc.gnu.org/g:352a0b5fc55c71f637108c7e91e161f87f620744

commit r17-5656-g352a0b5fc55c71f637108c7e91e161f87f620744
Author: Naveen <[email protected]>
Date:   Tue Oct 27 21:16:16 2026 -0700

    internal-fn: Optimize .MUL_OVERFLOW for sub-mode precision [PR116135]

    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.

    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]>

Reply via email to