Re: [PATCH] aarch64: allow usage of zero reg for CRC32 instructions
Kyrylo Tkachov <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi Shreesh. > On 13 Aug 2026, at 11:51, Shreesh Adiga <[email protected]> wrote: > > This avoids unnecessary moves when either the initial CRC > value or the data operand is a constant zero. For example: > __crc32w(0, x) previously generated "mov w1, 0; crc32w w0, w1, w0" > whereas now it generates "crc32w w0, wzr, w0". > The patch looks good to me, but it would be nice to have some simple tests in the test suite for this. Thanks, Kyrill > gcc/ChangeLog: > > * config/aarch64/aarch64.md: allow usage of zero reg for CRC32 > instructions > > Signed-off-by: Shreesh Adiga <[email protected]> > --- > gcc/config/aarch64/aarch64.md | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md > index 9cb55602c36..9f26e558e48 100644 > --- a/gcc/config/aarch64/aarch64.md > +++ b/gcc/config/aarch64/aarch64.md > @@ -4959,8 +4959,8 @@ (define_expand "<neg_not_op><mode>cc" > ;; CRC32 instructions. > (define_insn "aarch64_<crc_variant>" > [(set (match_operand:SI 0 "register_operand" "=r") > - (unspec:SI [(match_operand:SI 1 "register_operand" "r") > - (match_operand:<crc_mode> 2 "register_operand" "r")] > + (unspec:SI [(match_operand:SI 1 "aarch64_reg_or_zero" "rZ") > + (match_operand:<crc_mode> 2 "aarch64_reg_or_zero" "rZ")] > CRC))] > "TARGET_CRC32" > { > -- > 2.54.0 >