]> git.ipfire.org Git - thirdparty/gcc.git/commit
Make FOR_EACH_IMM_USE_STMT work w/o fake imm use node
authorRichard Biener <rguenther@suse.de>
Fri, 31 Oct 2025 12:08:05 +0000 (13:08 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 6 Nov 2025 13:55:27 +0000 (14:55 +0100)
commit9ded9b80c111559ece589197a17d6e7e512dd449
tree97e8494113941b979159b96c02b456a1d490001f
parent36c44c2d66664043ecfe0452bb34dff3b9994d70
Make FOR_EACH_IMM_USE_STMT work w/o fake imm use node

This is an attempt to fix PR122502 by making a FOR_EACH_IMM_USE_FAST
with in an FOR_EACH_IMM_USE_STMT on _the same_ VAR work without
the former running into the FOR_EACH_IMM_USE_STMT inserted marker
use operand.  It does this by getting rid of the marker.

The downside is that this in principle restricts the set of operations
that can be done on the immediate use list of VAR.  Where previously
almost anything was OK (but technically not well-defined what happens
to the iteration) after this patch you may only remove immediate
uses of VAR on the current stmt from the FOR_EACH_IMM_USE_STMT
iteration.  In particular things will break if you happen to remove
the one immediate use of VAR on the stmt immediately following
the set of immediate uses on the currrent stmt.

Additional checking to combat such cases is implemented in a
followup.

PR tree-optimization/122502
* ssa-iterators.h (imm_use_iterator::iter_node): Remove.
(imm_use_iterator::next_stmt_use): New.
(next_readonly_imm_use): Adjust checking code.
(end_imm_use_stmt_traverse): Simplify.
(link_use_stmts_after): Likewise.  Return the last use
with the same stmt.
(first_imm_use_stmt): Simplify.  Set next_stmt_use.
(next_imm_use_stmt): Likewise.
(end_imm_use_on_stmt_p): Adjust.

* gcc.dg/torture/pr122502-2.c: New testcase.
gcc/ssa-iterators.h
gcc/testsuite/gcc.dg/torture/pr122502-2.c [new file with mode: 0644]