From 4e0796d022fcd48c8af5a8a709577ce495bca991 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 7 Feb 2024 17:20:22 -0800 Subject: SimplifyGlobals: Propagate constant globals into nested gets in other globals (#6285) Before we propagated to the top level, but not to anything interior. --- src/passes/SimplifyGlobals.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/passes/SimplifyGlobals.cpp b/src/passes/SimplifyGlobals.cpp index 3baec4409..323ebd6a7 100644 --- a/src/passes/SimplifyGlobals.cpp +++ b/src/passes/SimplifyGlobals.cpp @@ -41,6 +41,7 @@ #include #include "ir/effects.h" +#include "ir/find_all.h" #include "ir/linear-execution.h" #include "ir/properties.h" #include "ir/utils.h" @@ -659,10 +660,11 @@ struct SimplifyGlobals : public Pass { // This is the init of a passive segment, which is null. return; } - if (auto* get = init->dynCast()) { + for (auto** getp : FindAllPointers(init).list) { + auto* get = (*getp)->cast(); auto iter = constantGlobals.find(get->name); if (iter != constantGlobals.end()) { - init = builder.makeConstantExpression(iter->second); + *getp = builder.makeConstantExpression(iter->second); } } }; -- cgit v1.2.3