On 7/26/24 12:05 PM, Mariam Arutunian wrote:
   Add two new internal functions (IFN_CRC, IFN_CRC_REV), to provide faster CRC generation.
    One performs bit-forward and the other bit-reversed CRC computation.
    If CRC optabs are supported, they are used for the CRC computation.
    Otherwise, table-based CRC is generated.
    The supported data and CRC sizes are 8, 16, 32, and 64 bits.
    The polynomial is without the leading 1.
    A table with 256 elements is used to store precomputed CRCs.
   For the reflection of inputs and the output, a simple algorithm involving
    SHIFT, AND, and OR operations is used.

   Co-authored-by: Joern Rennecke <joern.renne...@embecosm.com <mailto:joern.renne...@embecosm.com>>

    gcc/

        * doc/md.texi (crc@var{m}@var{n}4,
        crc_rev@var{m}@var{n}4): Document.
        * expr.cc (calculate_crc): New function.
        (assemble_crc_table): Likewise.
        (generate_crc_table): Likewise.
        (calculate_table_based_CRC): Likewise.
        (emit_crc): Likewise.
        (expand_crc_table_based): Likewise.
        (gen_common_operation_to_reflect): Likewise.
        (reflect_64_bit_value): Likewise.
        (reflect_32_bit_value): Likewise.
        (reflect_16_bit_value): Likewise.
        (reflect_8_bit_value): Likewise.
        (generate_reflecting_code_standard): Likewise.
        (expand_reversed_crc_table_based): Likewise.
       * expr.h (generate_reflecting_code_standard): New function declaration.
        (expand_crc_table_based): Likewise.
        (expand_reversed_crc_table_based): Likewise.
        * internal-fn.cc: (crc_direct): Define.
        (direct_crc_optab_supported_p): Likewise.
        (expand_crc_optab_fn): New function
        * internal-fn.def (CRC, CRC_REV): New internal functions.
        * optabs.def (crc_optab, crc_rev_optab): New optabs.

   Signed-off-by: Mariam Arutunian <mariamarutun...@gmail.com <mailto:mariamarutun...@gmail.com>>

0001-Implement-internal-functions-for-efficient-CRC-compu.patch

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 1baa39b98eb..c9a049aeecc 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc



+
+/* Converts and moves a CRC value to a target register.
+
+  CRC_MODE is the mode (data type) of the CRC value.
+  CRC is the initial CRC value.
+  OP0 is the target register.  */
+
+void
+emit_crc (machine_mode crc_mode, rtx* crc, rtx* op0)
+{
+  if (GET_MODE_BITSIZE (crc_mode).to_constant () == 32
+      && GET_MODE_BITSIZE (word_mode) == 64)
+    {
+      rtx a_low = gen_lowpart_SUBREG (crc_mode, *crc);
I may have asked this before, but is there a reason we're not just using gen_lowpart?


Otherwise this looks pretty reasonable.

Just a note. IIRC, you were having some problems with formatting issues. Rather than forcing you to fight with those, I'm comfortable if you send me the final patchkit and I'll do a once-over for formatting and commit the final result.

Jeff

Reply via email to