On 4/28/23 06:29, Jivan Hakobyan via Gcc-patches wrote:
RV64 the following code:

   unsigned Min(unsigned a, unsigned b) {
       return a < b ? a : b;
   }

Compiles to:
   Min:
        zext.w  a1,a1
        zext.w  a0,a0
        minu    a0,a1,a0
        sext.w  a0,a0
        ret

This patch removes unnecessary zero extensions of minu/maxu operands.

gcc/ChangeLog:

      * config/riscv/bitmanip.md: Added expanders for minu/maxu instructions

gcc/testsuite/ChangeLog:

    * gcc.target/riscv/zbb-min-max-02.c: Updated scanning check.
    * gcc.target/riscv/zbb-min-max-03.c: New tests.
Thanks. We had almost the exact same patch internally, the differences were just in naming rather than anything functional. I went ahead and installed your variant and I'll drop Raphael's from my queue.

I realize this may make some planned work WRT eliminating unnecessary extensions in gimple somewhat harder. If that work progresses to the point where this patch is a problem, then we'll re-evaluate. But it's crazy to hold this up -- it's a measurable win on x264 in particular.

Thanks again,
jeff

Reply via email to