[Bug tree-optimization/107090] [aarch64] sequence logic should be combined with mul and umulh

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107090

--- Comment #23 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:91cca3ac45e7f286e770536030da982d65615d4f

commit r17-3440-g91cca3ac45e7f286e770536030da982d65615d4f
Author: Konstantinos Eleftheriou <[email protected]>
Date:   Wed Jul 8 02:40:33 2026 -0700

    forwprop: Add long-multiply ladder variants

    Extend the long-multiply fold to the ladder forms, which propagate the
    cross-product carries via mask / shift / add steps on intermediate
    sums rather than via an explicit overflow compare:

      ladder_sum1     = (hilo & mask) + hilo' + (xl*yl >> N)
      ladder_part_sum = (xl*yl >> N) + hilo
      ladder_sum2     = (ladder_part_sum & mask) + hilo'
      ladder_sum3     = (hilo & mask) + (hilo' & mask) + (xl*yl >> N)

    The high-part chain is xh*yh + (hilo >> N) + (ladder_sumN >> N) [+ ...];
    the corresponding LOW_PART recovers (xl*yl & mask) | (ladder_sumN << N).

            PR tree-optimization/107090

    gcc/ChangeLog:

            * match.pd: Add mul_ladder_sum1, mul_ladder_sum2,
            mul_ladder_sum3 and mul_ladder_part_sum atom recognizers.
            * tree-ssa-forwprop.cc (gimple_mul_ladder_sum1): Declare.
            (gimple_mul_ladder_sum2): Likewise.
            (gimple_mul_ladder_sum3): Likewise.
            (gimple_mul_ladder_part_sum): Likewise.
            (enum long_mul_kind): Add LMK_LADDER_SUM1 / LMK_LADDER_SUM2
            / LMK_LADDER_SUM3 / LMK_LADDER_PART_SUM, with the
            long_mul_table HIGH_PART and LOW_PART rows for each ladder
            form.
            (long_mul_set_summand): Handle the new kinds.
            (long_mul_classify_carry): Update the specificity note above
            long_mul_classify_plus_kinds.
            (long_mul_classify_plus_kinds): Try mul_ladder_sum3 and
            mul_ladder_sum1 before mul_low_sum (more-constrained
            first); add mul_ladder_sum2.
            (long_mul_classify_hi_extract): Add mul_ladder_part_sum
            branch.
            (long_mul_classify_lo_extract): Adjust.

    gcc/testsuite/ChangeLog:

            * gcc.target/aarch64/long_mul.c: Add mulh_ladder and
            mulh_ladder_32 functions; bump expected umulh / umull
            scan counts from 1 to 2.
            * gcc.target/i386/long_mul.c: Same for mulq / imulq.
            * gcc.dg/tree-ssa/long-mul-ladder.c: New test.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.