On Fri, May 24, 2024 at 10:46 AM Mariam Arutunian
<mariamarutun...@gmail.com> wrote:
>
> This patch adds a new compiler pass aimed at identifying naive CRC 
> implementations,
> characterized by the presence of a loop calculating a CRC (polynomial long 
> division).
> Upon detection of a potential CRC, the pass prints an informational message.
>
> Performs CRC optimization if optimization level is >= 2,
> besides optimizations for size and if fno_gimple_crc_optimization given.
>
> This pass is added for the detection and optimization of naive CRC 
> implementations,
> improving the efficiency of CRC-related computations.
>
> This patch includes only initial fast checks for filtering out non-CRCs,
> detected possible CRCs verification and optimization parts will be provided 
> in subsequent patches.

Just a few quick questions - I'm waiting for a revision with Jeffs
comments cleared before
having a closer look.  The patch does nothing but analyze right now,
correct?  I assume
a later patch will fill in stuff in ::execute and use the return value
of loop_may_calculate_crc
(it's a bit odd to review such a "split" thing).

I think what this does fits final value replacement which lives in
tree-scalar-evolution.cc
and works from the loop-closed PHIs, trying to replace those.  I'm not
sure we want to
have a separate pass for this.  Consider a loop calculating two or
four CRCs in parallel,
replacing LC PHIs one-by-one should be able to handle this.

Richard.

>   gcc/
>
>     * Makefile.in (OBJS): Add gimple-crc-optimization.o.
>     * common.opt (fgimple-crc-optimization): New option.
>     * doc/invoke.texi (-fgimple-crc-optimization): Add documentation.
>     * gimple-crc-optimization.cc: New file.
>     * gimple.cc (set_phi_stmts_not_visited): New function.
>     (set_gimple_stmts_not_visited): Likewise.
>     (set_bbs_stmts_not_visited): Likewise.
>     * gimple.h (set_gimple_stmts_not_visited): New extern function 
> declaration.
>     (set_phi_stmts_not_visited): New extern function declaration.
>     (set_bbs_stmts_not_visited): New extern function declaration.
>     * opts.cc (default_options_table): Add OPT_fgimple_crc_optimization.
>     (enable_fdo_optimizations): Enable gimple-crc-optimization.
>     * passes.def (pass_crc_optimization): Add new pass.
>     * timevar.def (TV_GIMPLE_CRC_OPTIMIZATION): New timevar.
>     * tree-pass.h (make_pass_crc_optimization): New extern function 
> declaration.
>
> Signed-off-by: Mariam Arutunian <mariamarutun...@gmail.com>

Reply via email to