From cdbfaa06458117b9fcceb3cebbf53286f4f4f4bf Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 25 Feb 2026 12:01:11 -0800 Subject: [PATCH 1/2] clean --- src/passes/LocalCSE.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp index 79831fb89ab..a40c407fecd 100644 --- a/src/passes/LocalCSE.cpp +++ b/src/passes/LocalCSE.cpp @@ -441,7 +441,9 @@ struct Checker // Given the current expression, see what it invalidates of the currently- // hashed expressions, if there are any. if (!activeOriginals.empty()) { - EffectAnalyzer effects(options, *getModule()); + // We only need to visit this node itself, as we have already visited its + // children by the time we get here. + ShallowEffectAnalyzer effects(options, *getModule(), curr); // We can ignore traps here: // // (ORIGINAL) @@ -451,10 +453,13 @@ struct Checker // We are some code in between an original and a copy of it, and we are // trying to turn COPY into a local.get of a value that we stash at the // original. If |curr| traps then we simply don't reach the copy anyhow. + // + // Note, however, that this is really for future use, as atm this does not + // help: the only effect a trap can interact with is a set of global state + // (the trap could prevent that writing, which would be noticeable) - but + // LocalCSE does not deduplicate expressions with such effects, as they + // must happen twice. effects.trap = false; - // We only need to visit this node itself, as we have already visited its - // children by the time we get here. - effects.visit(curr); std::vector invalidated; for (auto& kv : activeOriginals) { From 8ad31d15531691f1e264eae22f37af67135e9724 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 25 Feb 2026 13:19:12 -0800 Subject: [PATCH 2/2] clarify --- src/passes/LocalCSE.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp index a40c407fecd..0fc2382c4bb 100644 --- a/src/passes/LocalCSE.cpp +++ b/src/passes/LocalCSE.cpp @@ -458,7 +458,9 @@ struct Checker // help: the only effect a trap can interact with is a set of global state // (the trap could prevent that writing, which would be noticeable) - but // LocalCSE does not deduplicate expressions with such effects, as they - // must happen twice. + // must happen twice. That is, removing trapping from (curr) in the + // example above has no effect as (ORIGINAL) never has global write + // effects. effects.trap = false; std::vector invalidated;