On 11/12/22 14:29, Philipp Tomsich wrote:
When if-conversion encounters sequences using immediates, the
sequences can't trivially map back onto vt.maskc/vt.maskcn (even if
benefitial) due to vt.maskc and vt.maskcn not having immediate forms.

This adds a splitter to rewrite opportunities for XVentanaCondOps that
operate on an immediate by first putting the immediate into a register
to enable the non-immediate vt.maskc/vt.maskcn instructions to operate
on the value.

Consider code, such as

   long func2 (long a, long c)
   {
     if (c)
       a = 2;
     else
       a = 5;
     return a;
   }

which will be converted to

   func2:
        seqz    a0,a2
        neg     a0,a0
        andi    a0,a0,3
        addi    a0,a0,2
        ret

Following this change, we generate

        li      a0,3
        vt.maskcn       a0,a0,a2
        addi    a0,a0,2
        ret

This commit also introduces a simple unit test for if-conversion with
immediate (literal) values as the sources for simple sets in the THEN
and ELSE blocks. The test checks that Ventana's conditional mask
instruction (vt.maskc<n>) is emitted as part of the resultant branchless
instruction sequence.

gcc/ChangeLog:

        * config/riscv/xventanacondops.md: Support immediates for
          vt.maskc/vt.maskcn through a splitter.

gcc/testsuite/ChangeLog:

         * gcc.target/riscv/xventanacondops-ifconv-imm.c: New test.

OK once we've cleared the non-technical hurdles to committing vendor specific extensions.


Jeff


Reply via email to