Hello,

just one question....

On Tue, Mar 15 2022, Joern Rennecke wrote:
> Most microprocessors have efficient ways to perform CRC operations, be
> that with lookup tables, rotates, or even special instructions.
> However, because we lack a representation for CRC in the compiler, we
> can't do proper instruction selection.  With this patch I seek out to
> rectify this,
> I've avoided using a mode name for the built-in functions because that
> would tie the semantics to the size of the addressable unit.  We
> generally use abbreviations like s/l/ll for type names, which is all
> right when the type can be widened without changing semantics.  For
> the data input, however, we also have to consider the shift count that
> is tied to it.  That is why I used a number to designate the width of
> the data input and shift.
>
> For machine support, I made a start with 8 and 16 bit little-endian
> CRC for RISCV using a
> lookup table.  I am sure once we have the basic infrastructure in the
> tree, we'll get more
> contributions of suitable named patterns for various ports.
>
> bootstrapped on x86_64-pc-linux-gnu .
> 2022-03-14  Jon Beniston  <j...@beniston.com>
>           Joern Rennecke  <joern.renne...@embecosm.com>
>
>       * Makefile.in (OBJS): Add tree-crc.o .
>       * builtin-types.def (BT_FN_UINT16_UINT16_UINT8_CONST_SIZE): Define.
>       (BT_FN_UINT16_UINT16_UINT16_CONST_SIZE): Likewise.
>       (BT_FN_UINT16_UINT16_UINT32_CONST_SIZE): Likewise.
>       * builtins.cc (associated_internal_fn):
>       Handle BUILT_IN_CRC8S, BUILT_IN_CRC16S, BUILT_IN_CRC32S.
>       * builtins.def (BUILT_IN_CRC8S, BUILT_IN_CRC16S, BUILT_IN_CRC32S):
>       New builtin functions.
>       * cgraph.cc (cgraph_node::verify_node):
>       Allow const calls without a callgraph edge.
>       * common.opt (fcrc): New option.
>       * doc/invoke.texi (-fcrc): Document.
>       * gimple-match-head.cc: #include predict.h .
>       * internal-fn.cc (crc_direct): Define.
>       (expand_crc_optab_fn): New function.
>       (direct_crc_optab_supported_p): Define.
>       * internal-fn.def (CRC, CRC_BE): New internal optab functions.
>       * match.pd: Match a pair of crc operations.
>       * optabs.def (crc_optab, crc_be_optab): New optabs.
>       * passes.def (pass_crc): Add new pass.
>       * tree-crc.cc: New file.
>       * tree-pass.h (make_pass_crc): Declare.
>
> testsuite:
>       * gcc.c-torture/compile/crc.c: New test.
>       * gcc.dg/tree-ssa/crc.c: Likewise.
>       * gcc.dg/tree-ssa/crc-2.c: likewise.
>       * gcc.dg/tree-ssa/pr59597.c: Add flag -fno-crc .
>
> config/riscv:
>       * crc.md: New file.
>       * riscv-protos.h (expand_crc_lookup, print_crc_table): Declare.
>       * riscv.cc (compute_crc): New function.
>       (print_crc_table, expand_crc_lookup): Likewise.
>       * riscv.md: Include crc.md.
>       * riscv.opt (msmall-memory): New option.
>       * tree-crc-doc.txt: New file.
>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 31ff95500c9..a901925511b 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -1612,6 +1612,7 @@ OBJS = \
>       tree-cfgcleanup.o \
>       tree-chrec.o \
>       tree-complex.o \
> +     tree-crc.o \
>       tree-data-ref.o \
>       tree-dfa.o \
>       tree-diagnostic.o \

[...]

> diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
> index b923a59ab0c..9570f5121af 100644
> --- a/gcc/cgraph.cc
> +++ b/gcc/cgraph.cc
> @@ -3793,7 +3793,8 @@ cgraph_node::verify_node (void)
>                           }
>                         e->aux = (void *)1;
>                       }
> -                   else if (decl)
> +                   else if (decl
> +                            && !TREE_READONLY (decl) && !DECL_PURE_P (decl))
>                       {
>                         error ("missing callgraph edge for call stmt:");
>                         cgraph_debug_gimple_stmt (this_cfun, stmt);

Why is this is necessary?  It seems that all other built-ins just have a
cgraph_node and their calls a cgraph_edge.

Thanks,

Martin

Reply via email to