On Fri, Nov 11, 2022 at 2:26 AM Kyrylo Tkachov via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi all,
>
> This patch adds codegen for FEAT_CSSC from the 2022 Architecture extensions.
> It fits various existing optabs in GCC quite well.
> There are instructions for scalar signed/unsigned min/max, abs, ctz, popcount.
> We have expanders for these already, so they are wired up to emit single-insn
> patterns for the new TARGET_CSSC.
>
> These instructions are enabled by the +cssc command-line extension.
> Bootstrapped and tested on aarch64-none-linux-gnu.
>
> I'll push it once the Binutils patch from Andre for this gets committed



@@ -4976,8 +5020,14 @@ (define_expand "ffs<mode>2"
 (define_expand "popcount<mode>2"
   [(match_operand:GPI 0 "register_operand")
    (match_operand:GPI 1 "register_operand")]
-  "TARGET_SIMD"
+  "TARGET_CSSC || TARGET_SIMD"
 {
+  if (TARGET_CSSC)
+    {
+      emit_insn (gen_aarch64_popcount<mode>2_insn (operands[0], operands[1]));
+      DONE;
+    }
+
   rtx v = gen_reg_rtx (V8QImode);
   rtx v1 = gen_reg_rtx (V8QImode);
   rtx in = operands[1];

I think the easy way is to this instead:
 (define_expand "popcount<mode>2"
   [(set (match_operand:GPI 0 "register_operand")
     (popcount:GPI  (match_operand:GPI 1 "register_operand")))]
  "TARGET_CSSC || TARGET_SIMD"
{
  if (!TARGET_CSSC)
    {
// Current code
     DONE;
    }
}

And then you don't need to name the aarch64_popcount pattern. Or use a *.
Yes it does mess up the diff but the end result seems cleaner.
I suspect all of the expands you are changing should be done this
similar way too.

Thanks,
Andrew Pinski

>
> Thanks,
> Kyrill
>
> gcc/ChangeLog:
>
>         * config/aarch64/aarch64-option-extensions.def (cssc): Define.
>         * config/aarch64/aarch64.h (AARCH64_ISA_CSSC): Define.
>         (TARGET_CSSC): Likewise.
>         * config/aarch64/aarch64.md (aarch64_abs<mode>2_insn): New 
> define_insn.
>         (abs<mode>2): Adjust for the above.
>         (aarch64_umax<mode>3_insn): New define_insn.
>         (umax<mode>3): Adjust for the above.
>         (aarch64_popcount<mode>2_insn): New define_insn.
>         (popcount<mode>2): Adjust for the above.
>         (<optab><mode>3): New define_insn.
>         * config/aarch64/constraints.md (Usm): Define.
>         (Uum): Likewise.
>         * 
> doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst:
>         Document +cssc.
>         * config/aarch64/iterators.md (MAXMIN_NOUMAX): New code iterator.
>         * config/aarch64/predicates.md (aarch64_sminmax_immediate): Define.
>         (aarch64_sminmax_operand): Likewise.
>         (aarch64_uminmax_immediate): Likewise.
>         (aarch64_uminmax_operand): Likewise.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/aarch64/cssc_1.c: New test.
>         * gcc.target/aarch64/cssc_2.c: New test.
>         * gcc.target/aarch64/cssc_3.c: New test.
>         * gcc.target/aarch64/cssc_4.c: New test.
>         * gcc.target/aarch64/cssc_5.c: New test.

Reply via email to