Skip to content

[feat] Puya: Global Value Numbering IR optimisation pass#726

Draft
achidlow wants to merge 178 commits into
mainfrom
gvn
Draft

[feat] Puya: Global Value Numbering IR optimisation pass#726
achidlow wants to merge 178 commits into
mainfrom
gvn

Conversation

@achidlow
Copy link
Copy Markdown
Contributor

@achidlow achidlow commented May 8, 2026

No description provided.

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 8, 2026

⚠️ No changelog fragment detected

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 8, 2026

Checking stubs for changes and corresponding version bump in origin/gvn

Last puyapy release: v5.8.1
This branch stubs version: 3.5.0
Last released stubs version: 3.5.0
Main stubs version: 3.5.0

✅ Stub files unchanged
✅ Stub check passed!

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 8, 2026

Name Status O0 bytes O1 bytes O2 bytes O0 ops O1 ops O2 ops
box_storage 🤔 - +3🔺 -3🟢 - +1🔺 +1
abi_routing/Reference 🟢 - -423🟢 -423 - -316🟢 -316
arc4_conversions/TestContract 🟢 - -116🟢 -116 - -92🟢 -92
arc4_types/Arc4AddressContract 🟢 - -10🟢 -10 - -7🟢 -7
arc4_types/Arc4MutableParamsContract 🟢 - -8🟢 - - -5🟢 -
arc4_types/Arc4RefTypesContract 🟢 - -32🟢 -32 - -18🟢 -18
arc4_types/Arc4StructsTypeContract 🤔 - -2🟢 -2 - +4🔺 +4
array/ImmutableArrayContract 🟢 - -2🟢 -2 - -1🟢 -1
array/StaticSizeContract 🟢 - -5🟢 -5 - -2🟢 -3🟢
avm_11 🟢 - -6🟢 -6 - -4🟢 -4
bytes_backed_ops 🟢 - -40🟢 -40 - -18🟢 -18
conditional_expressions/Literals 🟢 - -9🟢 - - -7🟢 -
fixed_bytes_ops/FixedBytesOps 🟢 - -62🟢 -62 - -42🟢 -42
gvn/ComparisonSwapsContract 🆕 +95 +58 +58 +52 +31 +31
gvn/GVNConstFolding 🆕 +441 +120 +117 +226 +35 +34
gvn/GetByteConstFoldContract 🆕 +84 +21 +21 +41 +10 +10
gvn/NegatedComparisonContract 🆕 +180 +102 +102 +110 +60 +60
gvn/PRE 🆕 +143 +81 +81 +70 +40 +40
gvn/PhiCongruenceContract 🆕 +226 +134 +134 +119 +79 +79
gvn/Replace3ConstFoldContract 🆕 +88 +21 +21 +41 +10 +10
gvn/WideMathConstFoldContract 🆕 +157 +28 +28 +84 +14 +14
inner_transactions/FieldTupleContract 🔺 - +1🔺 +1 - - -
inner_transactions/MyContract 🟢 - -23🟢 -23 - -18🟢 -18
intrinsics/ImmediateVariants 🟢 - -36🟢 -36 - -20🟢 -20
large_box_operations/ArrayUInt64 🟢 - -1🟢 -1 - - -
literals 🟢 - -7🟢 -7 - -8🟢 -8
log 🟢 - -22🟢 -22 - -21🟢 -21
logic_signature/args_complex 🟢 - -195🟢 -195 - -133🟢 -133
logic_signature/args_complex_no_validation 🟢 - -196🟢 -196 - -133🟢 -133
logic_signature/args_simple 🟢 - -16🟢 -16 - -11🟢 -11
mutable_native_types/Case1WithTups 🟢 - -2🟢 -2 - - -
mutable_native_types/Case2WithImmStruct 🟢 - -2🟢 -2 - - -
mutable_native_types/Contract 🟢 - -32🟢 -32 - -24🟢 -24
mutable_native_types/TestAbiCall 🟢 - -42🟢 -42 - -35🟢 -35
mutable_native_types/TestItxnAbiCall 🟢 - -42🟢 -42 - -35🟢 -35
regression_tests/ReplaceOpSelection 🟢 - -535🟢 -535 - -7🟢 -7
statically_failing_ops 🟢 - -2🟢 -2 - -2🟢 -2
string_ops 🟢 - -13🟢 -13 - -9🟢 -9
tuple_support/NestedTuples 🟢 - -15🟢 -15 - -14🟢 -14
tuple_support/TupleSupport 🟢 - -35🟢 -35 - -18🟢 -18
typed_abi_call/Logger 🟢 - -82🟢 -82 - -57🟢 -57
typed_itxn_abi_call/Logger 🟢 - -82🟢 -82 - -57🟢 -57
undefined_phi_args/RuntimeDominance 🆕 +86 +59 +59 +43 +33 +33
logical_fold_or_identity 🟢 - -8🟢 -8 - -7🟢 -7
Total 🟢 - -2099🟢 -2088🟢 - -1116🟢 -1105🟢

@engineering-ci
Copy link
Copy Markdown

engineering-ci Bot commented May 8, 2026

Coverage

Tests Skipped Failures Errors Time
1709 3 💤 0 ❌ 0 🔥 12m 42s ⏱️

@achidlow achidlow force-pushed the gvn branch 2 times, most recently from 766c9a4 to e2ba965 Compare May 15, 2026 02:32
achidlow added 24 commits May 18, 2026 10:16
- introduce types for "expression" keys
- use AVMOp instead of str
…d should definitely not be considered equal, and compiled refs get replaced by constants eventually anyway.
- add ArrayPop & ArrayConcat handling to GVN
…e violation

_vn_to_register, _const_vn, and _comparison_exprs were shared globally
across the dominator-tree walk. This meant a register-to-register copy
in one branch could be replaced with a representative register from a
sibling branch (via shared constant VNs), violating SSA dominance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant