On Dec 5, 2025, Eric Botcazou <[email protected]> wrote:
> The cselib_invalidate_mem change looks a bit risky at this stage if it does
> not really fix anything.
It does fix at least incorrect (excessive) invalidation of on-stack
values during pushes for calls, but those are mostly ephemeral and
rarelly benefit from cse, so I can live with this ;-)
With the PR122947 fix in, what remains is probably just missed
optimizations involving other on-stack values that could conceivably
undergo CSE but don't because IIRC the pushes incorrectly invalidate
them.
> The rest is OK of course.
Thanks. Here's the bit I'm putting in for now.
Rework dump_cselib_table to not crash when cselib_preserved_hash_table
is not allocated, and to remove the extraneous indirection from
dump_cselib_val that made it inconvenient to call from a debugger.
for gcc/ChangeLog
* cselib.cc (dump_cselib_val): Split out of and rename to...
(dump_cselib_val_ptr): ... this.
(dump_cselib_table): Adjust. Skip cselib_preserved_hash_table
when not allocated.
---
gcc/cselib.cc | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index 7f1991b09c3c8..930357409bc54 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -3459,12 +3459,11 @@ cselib_finish (void)
next_uid = 0;
}
-/* Dump the cselib_val *X to FILE *OUT. */
+/* Dump the cselib_val V to FILE *OUT. */
int
-dump_cselib_val (cselib_val **x, FILE *out)
+dump_cselib_val (cselib_val *v, FILE *out)
{
- cselib_val *v = *x;
bool need_lf = true;
print_inline_rtx (out, v->val_rtx, 0);
@@ -3533,15 +3532,27 @@ dump_cselib_val (cselib_val **x, FILE *out)
return 1;
}
+/* Dump the cselib_val *X to FILE *OUT. */
+
+static int
+dump_cselib_val_ptr (cselib_val **x, FILE *out)
+{
+ cselib_val *v = *x;
+ return dump_cselib_val (v, out);
+}
+
/* Dump to OUT everything in the CSELIB table. */
void
dump_cselib_table (FILE *out)
{
fprintf (out, "cselib hash table:\n");
- cselib_hash_table->traverse <FILE *, dump_cselib_val> (out);
- fprintf (out, "cselib preserved hash table:\n");
- cselib_preserved_hash_table->traverse <FILE *, dump_cselib_val> (out);
+ cselib_hash_table->traverse <FILE *, dump_cselib_val_ptr> (out);
+ if (cselib_preserved_hash_table)
+ {
+ fprintf (out, "cselib preserved hash table:\n");
+ cselib_preserved_hash_table->traverse <FILE *, dump_cselib_val_ptr>
(out);
+ }
if (first_containing_mem != &dummy_val)
{
fputs ("first mem ", out);
--
Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/
Free Software Activist FSFLA co-founder GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!