On 8/8/2021 4:48 AM, Roger Sayle wrote:
This middle-end patch teaches RTL expansion to recognize widening multiplications followed by right shifts as highpart multiplications, and attempt to emit them using the backends [su]mul_highpart optab if possible. My first attempt at supporting this, from August 2020, is at: https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551316.html and the nvptx portions were conditionally pre-approved here: https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551373.html I completely agree with Richard's original review that it's best to avoid any potential problems with MULT_HIGHPART_EXPR, which is poorly supported by middle-end passes, by recognizing this later, during expansion to RTL, which is the approach implemented in the patch. https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553055.html The following patch has been tested on nvptx-none with a "make" and "make -k check", and on x86-pc-linux-gnu with a "make bootstrap" and "make -k check" both with no new failures. Future work may also support WIDEN_MULT_EXPR and larger shifts, but the current matching is already complex enough for v1.0. Ok for mainline? 2021-08-08 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog * expr.c (try_expand_mult_highpart): New function to recognize a highpart multiplication and expand it using the appropriate optab. (expand_expr_real_2) [RSHIFT_EXPR]: Attempt to expand right shifts of widening multiplications using try_expand_mult_highpart. * config/nvptx/nvptx.md (smuldi3_highpart): New define_insn. (umuldi3_highpart): New define_insn. gcc/testsuite/ChangeLog * gcc.target/nvptx/mul-hi64.c: New test case. * gcc.target/nvptx/umul-hi64.c: New test case.
ENOPATCH jeff