On Tue, Sep 22, 2026 at 9:22 AM Roger Sayle <[email protected]> wrote:
>
>
> This patch adds some RTL simplifications for SMUL_HIGHPART and
> UMUL_HIGHPART.  Currently, simplify_binary_operation_1 knows
> that highpart multiplication by zero is zero.  This patch
> optimizes unsigned highpart multiplication (UMUL_HIGHPART) by
> 1 to zero, and signed highpart multiplication (SMUL_HIGHPART)
> by one to be the repeated signbit, x < 0 ? -1 : 0, i.e.
> x >> PRECISION-1.  Additionally, UMUL_HIGHPART by a power
> of two is transformed into a logical right shift, and
> SMUL_HIGHPART by a positive power of two is transformed into
> an arithmetic right shift.
>
> This patch has been tested on x86_64-pc-linux-gnu with make
> bootstrap and make -k check (to confirm it does no harm) and
> on a cross-compiler to nvptx-none, with make and make -k check
> with no new failures (to confirm it benefits targets with a
> highpart multiplication instruction/pattern).
>
> Ok for mainline?

Ok.

>
>
> 2026-09-22  Roger Sayle  <[email protected]>
>
> gcc/ChangeLog
>         * simplify_rtx.cc (simplify_binary_operation_1) <SMUL_HIGHPART>:
>         Add transformations for multiplications by one and powers to two.
>         <UMUL_HIGHPART>: Likewise.
>
> gcc/testsuite/ChangeLog
>         * gcc.target/nvptx/mul-hi-2.c: New test case.
>
>
> Thanks in advance,
> Roger
> --
>

Reply via email to