Summary
--llzk-duplicate-op-elim can reuse a global.read or ram.load across an intervening write/store to the same state.
Reproduction
Reproducer run:
https://github.com/Kuhai9801/llzk-lib/actions/runs/28180228869
Global read/write:
global.def @g : !felt.type = 1
function.def @compute() -> !struct.type<@GlobalState> {
%self = struct.new : !struct.type<@GlobalState>
%two = felt.const 2
%before = global.read @g : !felt.type
global.write @g = %two : !felt.type
%after = global.read @g : !felt.type
struct.writem %self[@out] = %after : !struct.type<@GlobalState>, !felt.type
function.return %self : !struct.type<@GlobalState>
}
Run: llzk-opt --llzk-duplicate-op-elim repro.llzk
Actual: later uses are rewritten to the first global.read / ram.load.
Expected
The second global.read @g and second ram.load %addr remain after the intervening write/store.
Actual
The later read/load is removed and its uses are rewritten to the earlier read/load result.
Notes
The relevant pass is in lib/Transforms/LLZKRedundantOperationEliminationPass.cpp.
Summary
--llzk-duplicate-op-elimcan reuse aglobal.readorram.loadacross an intervening write/store to the same state.Reproduction
Reproducer run:
https://github.com/Kuhai9801/llzk-lib/actions/runs/28180228869
Global read/write:
Run:
llzk-opt --llzk-duplicate-op-elim repro.llzkActual: later uses are rewritten to the first
global.read/ram.load.Expected
The second
global.read @gand secondram.load %addrremain after the intervening write/store.Actual
The later read/load is removed and its uses are rewritten to the earlier read/load result.
Notes
The relevant pass is in
lib/Transforms/LLZKRedundantOperationEliminationPass.cpp.