https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127042
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Philipp Tomsich <[email protected]>: https://gcc.gnu.org/g:2d2e355b89367711f549b1277a537e2c0a4de58d commit r17-4493-g2d2e355b89367711f549b1277a537e2c0a4de58d Author: Philipp Tomsich <[email protected]> Date: Mon Aug 24 17:13:40 2026 +0200 widening_mul: Emit zero high-half partials for operands that fit [PR127042] 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]>
