Hi Martin,

Thanks for the review.  I split the ipa-cp part you suggested into a
new patch, attached.  Please take a look.

If anything is not going well, please tell me; I would really appreciate it.

Thanks,
Linden



On Thu, Sep 24, 2026 at 8:36 PM Martin Jambor <[email protected]> wrote:
>
> Hello,
>
> On Thu, Sep 24 2026, best xmg wrote:
> > Hi all,
> >
> > Reference and move semantics are a part of C++ that experienced engineers
> > still get subtly wrong, so I audited the tree with clang-tidy's
> > performance-* checks, which trace whether a by-value parameter is ever
> > mutated or a std::move target is actually reachable -- the kind of
> > exhaustive per-parameter check regular compiler warnings and human review
> > aren't built to do. Only patch 1 has a measured performance number;
> > patches 2-5 are correctness/consistency fixes in the same spirit with no
> > individual perf claim. No functional change is intended anywhere in the
> > series.
> >
> > Patch 1 removes a needless deep-copy of program_state (which owns a whole
> > region_model) when -fanalyzer creates an exploded_node, by giving
> > program_state a move-assignment operator and threading the move through
> > point_and_state and exploded_node.
> >
> > Testing:
> > - x86_64-pc-linux-gnu, --enable-languages=c,c++,lto, --disable-bootstrap.
> > - check-gcc analyzer.exp/tree-ssa.exp/ipa.exp on current trunk
> > (492fbdbf99d): 16820+10537 pass. Same 2 pre-existing failures as
> > unpatched trunk, unrelated to this series:
> > * omp-parallel-for-1.c: -Wanalyzer-symbol-too-complex depth boundary.
> > * ssa-sink-18.c: known r17-3756 regression (unrelated ivopts change).
> > - Timing (patch 1 only): 8 interleaved `cc1 -fanalyzer` runs on
> > libiberty/cp-demangle.c, binary swapped each run: 63.98s -> 60.10s
> > median (6.06% faster), no overlap across all 8 pairs.
> >
> > Full test logs and the benchmark script are available on request.
>
> The ipa-cp.cc and ipa-cp.h hunks are OK.
>
> >
> > I don't have push access; posting for review. Happy to split patch 1
> > out on its own if that's preferred, or to fold 2-5 together -- they're
> > independent of each other and of patch 1.
>
> If you carve these to a separate patch, I can push t on your behalf.
> (The other bits in the patch need to be approved by someone else.)
>
> Thanks,
>
> Martin
From 019707ee400e6c428e1caf6e0c87016c31d5cae7 Mon Sep 17 00:00:00 2001
From: linden <[email protected]>
Date: Sat, 26 Sep 2026 18:41:54 +1200
Subject: [PATCH 5/7] ipa-cp: take widest_int parameters by const reference

widest_int is a large inline-buffer type, and
ipcp_bits_lattice::set_to_constant, meet_with and meet_with_1 only read
these parameters.  Take them by const reference instead of copying;
no functional change.

gcc/ChangeLog:
        * ipa-cp.h (ipcp_bits_lattice::set_to_constant)
        (ipcp_bits_lattice::meet_with, ipcp_bits_lattice::meet_with_1):
        Take widest_int parameters by const reference.
        * ipa-cp.cc (ipcp_bits_lattice::set_to_constant)
        (ipcp_bits_lattice::meet_with, ipcp_bits_lattice::meet_with_1):
        Likewise.

Signed-off-by: linden <[email protected]>
---
 gcc/ipa-cp.cc | 9 ++++++---
 gcc/ipa-cp.h  | 6 +++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index d0428d04684..574b109bad5 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -928,7 +928,8 @@ ipcp_bits_lattice::set_to_bottom ()
    when switching state from TOP.  */
 
 bool
-ipcp_bits_lattice::set_to_constant (widest_int value, widest_int mask)
+ipcp_bits_lattice::set_to_constant (const widest_int &value,
+                                   const widest_int &mask)
 {
   gcc_assert (top_p ());
   m_lattice_val = IPA_BITS_CONSTANT;
@@ -985,7 +986,8 @@ ipcp_bits_lattice::get_value_and_mask (tree operand, 
widest_int *valuep, widest_
    DROP_ALL_ONES, mask out any known bits with value one afterwards.  */
 
 bool
-ipcp_bits_lattice::meet_with_1 (widest_int value, widest_int mask,
+ipcp_bits_lattice::meet_with_1 (const widest_int &value,
+                               const widest_int &mask,
                                unsigned precision, bool drop_all_ones)
 {
   gcc_assert (constant_p ());
@@ -1008,7 +1010,8 @@ ipcp_bits_lattice::meet_with_1 (widest_int value, 
widest_int mask,
    described by <value, mask, sgn, precision.  */
 
 bool
-ipcp_bits_lattice::meet_with (widest_int value, widest_int mask,
+ipcp_bits_lattice::meet_with (const widest_int &value,
+                             const widest_int &mask,
                              unsigned precision)
 {
   if (bottom_p ())
diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h
index af1fe8f1e75..c22a74bb23f 100644
--- a/gcc/ipa-cp.h
+++ b/gcc/ipa-cp.h
@@ -199,7 +199,7 @@ public:
   bool top_p () const { return m_lattice_val == IPA_BITS_UNDEFINED; }
   bool constant_p () const { return m_lattice_val == IPA_BITS_CONSTANT; }
   bool set_to_bottom ();
-  bool set_to_constant (widest_int, widest_int);
+  bool set_to_constant (const widest_int &, const widest_int &);
   bool known_nonzero_p () const;
   bool set_recipient_only ();
   bool recipient_only_p () const {return m_recipient_only; }
@@ -210,7 +210,7 @@ public:
   bool meet_with (ipcp_bits_lattice& other, unsigned, signop,
                  enum tree_code, tree, bool);
 
-  bool meet_with (widest_int, widest_int, unsigned);
+  bool meet_with (const widest_int &, const widest_int &, unsigned);
 
   void print (FILE *);
 
@@ -228,7 +228,7 @@ private:
      value is known to be constant.  */
   widest_int m_value, m_mask;
 
-  bool meet_with_1 (widest_int, widest_int, unsigned, bool);
+  bool meet_with_1 (const widest_int &, const widest_int &, unsigned, bool);
   void get_value_and_mask (tree, widest_int *, widest_int *);
 };
 
-- 
2.53.0

Reply via email to