]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add gather_imm_use_stmts helper
authorRichard Biener <rguenther@suse.de>
Tue, 4 Nov 2025 09:48:44 +0000 (10:48 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 5 Nov 2025 08:34:09 +0000 (09:34 +0100)
commit07a2b1a40cfe3e695eef970e98cc5f682a0b79a7
tree5e9b71a456a938ac40f871eed1a132c0a6d2dfc3
parentb9457ed89cd84c609482a6d808e1bbdbe2cd84ac
Add gather_imm_use_stmts helper

The following adds a helper function to gather SSA use stmts without
duplicates.  It steals the only padding bit in gimple to be a
"infrastructure local flag" which should be used only temporarily
and kept cleared.  I did not add accessor functions for the flag
to not encourage (ab-)uses.

I have used an auto_vec<gimple *, 2> in the API to avoid heap
allocations for most cases (without doing statistics).  I have
verified GCC 7 performs NRV optimization on the copy but I'll
note while auto_vec<gimple *> has copy and assign deleted,
auto_vec<gimple *, N> does not.  Adding them breaks pair-fusion.cc
compile.  Without using 'auto' or range-for the API use is a bit
awkward as that exposes the number of auto-allocated elements.

The helper can be used in a range-for, see the followup for an
example.

* gimple.h (gimple::pad): Rename to ...
(gimple::ilf): ... this.
* ssa-iterators.h (gather_imm_use_stmts): Declare.
* tree-ssa-operands.cc (gather_imm_use_stmts): New function.
gcc/gimple.h
gcc/ssa-iterators.h
gcc/tree-ssa-operands.cc