]> git.ipfire.org Git - thirdparty/gcc.git/commit
Re: [PATCH] RISC-V: fix scalar crypto patterns
authorJeff Law <jlaw@ventanamicro.com>
Fri, 15 Dec 2023 21:19:25 +0000 (14:19 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Fri, 15 Dec 2023 21:29:30 +0000 (14:29 -0700)
commit082835836cf763e74ed2fdf9645ac4f1f94d6d4f
treeef8070341357e41a57869b9098e37b4c81f4e5cf
parenta1f0d227481fe143f8c15b3f268e2d5964a3c90a
Re: [PATCH] RISC-V: fix scalar crypto patterns

A handful of the scalar crypto instructions are supposed to take a
constant integer argument 0..3 inclusive and one should accept 0..10.
A suitable constraint was created and used for this purpose (D03 and DsA),
but the operand's predicate is "register_operand".  That's just wrong.

This patch adds a new predicates "const_0_3_operand" and "const_0_10_operand"
and fixes the relevant insns to use the appropriate predicate.   It drops the
now unnecessary constraints.

The testsuite was broken in a way that made it consistent with the
compiler, so the tests passed, when they really should have been issuing
errors all along.

This patch adjusts the existing tests so that they all expect a
diagnostic on the invalid operand usage (including out of range
constants).  It adds new tests with proper constants, testing the
extremes of valid values.

PR target/110201

gcc/

* config/riscv/constraints.md (D03, DsA): Remove unused constraints.
* config/riscv/predicates.md (const_0_3_operand): New predicate.
(const_0_10_operand): Likewise.
* config/riscv/crypto.md (riscv_aes32dsi): Use new predicate.  Drop
unnecessary constraint.
(riscv_aes32dsmi, riscv_aes64im, riscv_aes32esi): Likewise.
(riscv_aes32esmi, *riscv_<sm4_op>_si): Likewise.
(riscv_<sm4_op>_di_extend, riscv_<sm4_op>_si): Likewise.

gcc/testsuite
* gcc.target/riscv/zknd32.c: Verify diagnostics are issued for
invalid builtin arguments.
* gcc.target/riscv/zknd64.c: Likewise.
* gcc.target/riscv/zkne32.c: Likewise.
* gcc.target/riscv/zkne64.c: Likewise.
* gcc.target/riscv/zksed32.c: Likewise.
* gcc.target/riscv/zksed64.c: Likewise.
* gcc.target/riscv/zknd32-2.c: New test
* gcc.target/riscv/zknd64-2.c: Likewise.
* gcc.target/riscv/zkne32-2.c: Likewise.
* gcc.target/riscv/zkne64-2.c: Likewise.
* gcc.target/riscv/zksed32-2.c: Likewise.
* gcc.target/riscv/zksed64-2.c: Likewise.

Co-authored-by: Liao Shihua <shihua@iscas.ac.cn>
15 files changed:
gcc/config/riscv/constraints.md
gcc/config/riscv/crypto.md
gcc/config/riscv/predicates.md
gcc/testsuite/gcc.target/riscv/zknd32-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zknd32.c
gcc/testsuite/gcc.target/riscv/zknd64-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zknd64.c
gcc/testsuite/gcc.target/riscv/zkne32-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zkne32.c
gcc/testsuite/gcc.target/riscv/zkne64-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zkne64.c
gcc/testsuite/gcc.target/riscv/zksed32-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zksed32.c
gcc/testsuite/gcc.target/riscv/zksed64-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zksed64.c