[zeek/spicy] 08a055: Optimize grouping with side-effect free local vari...

0 views
Skip to first unread message

Robin Sommer

unread,
Mar 3, 2026, 3:27:39 AM (10 days ago) Mar 3
to spicy-...@zeek.org
Branch: refs/heads/topic/robin/opt-groupings
Home: https://github.com/zeek/spicy
Commit: 08a055295927521ceed1ac054c616b11b555518e
https://github.com/zeek/spicy/commit/08a055295927521ceed1ac054c616b11b555518e
Author: Robin Sommer <ro...@corelight.com>
Date: 2026-03-03 (Tue, 03 Mar 2026)

Changed paths:
M hilti/toolchain/include/ast/expressions/grouping.h
M hilti/toolchain/src/compiler/optimizer/passes/peephole.cc
M tests/Baseline/hilti.expressions.grouping-with-local/output
M tests/Baseline/hilti.optimization.unimplemented_hook/log
M tests/Baseline/spicy.optimization.default-parser-functions/log
M tests/Baseline/spicy.optimization.feature_requirements/log
M tests/Baseline/spicy.optimization.unused-functions/log
M tests/Baseline/spicy.optimization.unused-types/log
M tests/hilti/expressions/grouping-with-local.hlt

Log Message:
-----------
Optimize grouping with side-effect free local variables.

Our resolver can sometimes leave new groupings behind that are more
complex than necessary because they introduce local temporary
variables even though their value is constant and side-effect free.
The problem is that the resolver can't tell if something is
side-effect free (that needs data flow analysis) and hence it needs to
remain conservative.

This commit adds a peephole optimization that removes local variables
from groupings if they aren't necessary. We generally prefer repeating
the side-effect expressions for readability and further optimizations
down the line.



To unsubscribe from these emails, change your notification settings at https://github.com/zeek/spicy/settings/notifications
Reply all
Reply to author
Forward
0 new messages