On 8/26/26 9:06 AM, Konstantinos Eleftheriou wrote:
From: Philipp Tomsich <[email protected]>

build_long_mul_partials splits both operands into halves regardless of
what is known about them. An operand provably within the half width
still gets a shift and two partial products against its high half,
which is zero. They reach expand, and the carry arithmetic built on top
of them survives into the final code.

Reuse the recognizer's fits test: a provably-fitting operand keeps its
low half unmasked and contributes literal zeros as high-half partials,
so the cross sum, carry test and accumulate fold as the sequence is
built. The u16-operand high part comes out as the two multiplies it
needs.

Bootstrapped and regtested on AArch64, x86-64 and ARM.
Regtested on AVR.

        PR tree-optimization/127042

gcc/ChangeLog:

        * tree-ssa-math-opts.cc (build_long_mul_partials): Emit zero
        high-half partial products, and skip the high-half split and
        the low-half mask, for an operand that provably fits the half
        width.

gcc/testsuite/ChangeLog:

        * gcc.target/arm/pr127042.c: New test.
        * gcc.target/avr/mmcu/pr127042.c: New test.

Co-authored-by: Konstantinos Eleftheriou <[email protected]>
Signed-off-by: Konstantinos Eleftheriou <[email protected]>
OK
jeff

Reply via email to