On Tue, Nov 12, 2024 at 2:32 AM Jeff Law <jeffreya...@gmail.com> wrote:

>
>
> On 11/9/24 12:44 PM, Mariam Arutunian 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 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.
> >
> >    gcc/
> >
> >      * Makefile.in (OBJS): Add gimple-crc-optimization.o.
> >      * common.opt (foptimize-crc): New option.
> >      * common.opt.urls: Regenerate to add foptimize-crc.
> >      * doc/invoke.texi (-foptimize-crc): Add documentation.
> >      * gimple-crc-optimization.cc: New file.
> >      * opts.cc (default_options_table): Add OPT_foptimize_crc.
> >      (enable_fdo_optimizations): Enable optimize_crc.
> >      * 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
> > <mailto:mariamarutun...@gmail.com>>
> > Mentored-by: Jeff Law <j...@ventanamicro.com <mailto:
> j...@ventanamicro.com>>
>
>
> > ---
> >  gcc/Makefile.in                |    1 +
> >  gcc/common.opt                 |   10 +
> >  gcc/common.opt.urls            |    3 +
> >  gcc/doc/invoke.texi            |   16 +-
> >  gcc/gimple-crc-optimization.cc | 1000 ++++++++++++++++++++++++++++++++
> >  gcc/opts.cc                    |    2 +
> >  gcc/passes.def                 |    1 +
> >  gcc/timevar.def                |    1 +
> >  gcc/tree-pass.h                |    1 +
> >  9 files changed, 1034 insertions(+), 1 deletion(-)
> >  create mode 100644 gcc/gimple-crc-optimization.cc
> >
>
> > diff --git a/gcc/gimple-crc-optimization.cc
> b/gcc/gimple-crc-optimization.cc
> > new file mode 100644
> > index 00000000000..c67b0fd38c3
> > --- /dev/null
> > +++ b/gcc/gimple-crc-optimization.cc
> > @@ -0,0 +1,1000 @@
> > +/* CRC optimization.
> > +   Copyright (C) 2022-2024 Free Software Foundation, Inc.
> > +   Contributed by Mariam Arutunian <mariamarutun...@gmail.com>
> > +
> > +This file is part of GCC.
> > +
> > +GCC is free software; you can redistribute it and/or modify it under
> > +the terms of the GNU General Public License as published by the Free
> > +Software Foundation; either version 3, or (at your option) any later
> > +version.
> > +
> > +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> > +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> > +for more details.
> > +
> > +You should have received a copy of the GNU General Public License
> > +along with GCC; see the file COPYING3.  If not see
> > +<http://www.gnu.org/licenses/>.   */
> > +
> > +/* This pass performs CRC optimization.  */
> > +#include "config.h"
> > +#include "system.h"
> > +#include "coretypes.h"
> > +#include "backend.h"
> > +#include "tree.h"
> > +#include "gimple.h"
> > +#include "tree-pass.h"
> > +#include "ssa.h"
> > +#include "gimple-iterator.h"
> > +#include "tree-cfg.h"
> > +#include "cfgloop.h"
> > +#include "tree-scalar-evolution.h"
> So there's been some changes in the trunk and this patch (and a few
> others) need
> #define INCLUDE_MEMORY before the various #includes.  I've fixed all
> these in my local tree.
>
>
>
> > diff --git a/gcc/timevar.def b/gcc/timevar.def
> > index 0f9d2c0b032..37460def292 100644
> > --- a/gcc/timevar.def
> > +++ b/gcc/timevar.def
> > @@ -313,6 +313,7 @@ DEFTIMEVAR (TV_INITIALIZE_RTL        , "initialize
> rtl")
> >  DEFTIMEVAR (TV_GIMPLE_LADDRESS       , "address lowering")
> >  DEFTIMEVAR (TV_TREE_LOOP_IFCVT       , "tree loop if-conversion")
> >  DEFTIMEVAR (TV_WARN_ACCESS           , "access analysis")
> > +DEFTIMEVAR (TV_GIMPLE_CRC_OPTIMIZATION, "crc optimization")
> >
> >  /* Everything else in rest_of_compilation not included above.  */
> >  DEFTIMEVAR (TV_EARLY_LOCAL        , "early local passes")
> This has a trivial conflict with a recent change in the tree.  I've
> resolved the conflict locally.
>

Thank you very much!
I applied the patches to the GCC upstream at commit hash bfb9105ff, which
currently appears as the latest version.
Could you confirm if this is the latest?

Thanks,
Mariam


>
jeff
>
>

Reply via email to