Skip to content

Commit 6231602

Browse files
authored
chore: Remove RC tracking in mem2reg (#6019)
# Description ## Problem\* Resolves <!-- Link to GitHub Issue --> #5935 added logic to remove trivial stores, however, it also had to track whether the alst instruction was an `inc_rc` or `dec_rc` instruction. After AztecProtocol/aztec-packages#8448 we can remove that logic. ## Summary\* Removes `inside_rc_reload` from mem2reg, its tracking method, and its ussage. Before AztecProtocol/aztec-packages#8448 we were creating extra trivial stores. The majority of the code size benefit comes from that PR avoiding the creation of those stores in the first place. This PR is truly simply a clean-up that removes unnecessary logic. I do not foresee large bytecode size increases from this removal as the majority of the benefit came in the new array layout. ## Additional Context ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [X] I have tested the changes locally. - [X] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
1 parent fc5bb02 commit 6231602

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ struct PerFunctionContext<'f> {
117117
/// Track a value's last load across all blocks.
118118
/// If a value is not used in anymore loads we can remove the last store to that value.
119119
last_loads: HashMap<ValueId, (InstructionId, BasicBlockId)>,
120-
121-
/// Track whether the last instruction is an inc_rc/dec_rc instruction.
122-
/// If it is we should not remove any known store values.
123-
inside_rc_reload: bool,
124120
}
125121

126122
impl<'f> PerFunctionContext<'f> {
@@ -135,7 +131,6 @@ impl<'f> PerFunctionContext<'f> {
135131
blocks: BTreeMap::new(),
136132
instructions_to_remove: BTreeSet::new(),
137133
last_loads: HashMap::default(),
138-
inside_rc_reload: false,
139134
}
140135
}
141136

@@ -324,7 +319,7 @@ impl<'f> PerFunctionContext<'f> {
324319
let known_value = references.get_known_value(value);
325320
if let Some(known_value) = known_value {
326321
let known_value_is_address = known_value == address;
327-
if known_value_is_address && !self.inside_rc_reload {
322+
if known_value_is_address {
328323
self.instructions_to_remove.insert(instruction);
329324
}
330325
}
@@ -383,18 +378,6 @@ impl<'f> PerFunctionContext<'f> {
383378
Instruction::Call { arguments, .. } => self.mark_all_unknown(arguments, references),
384379
_ => (),
385380
}
386-
387-
self.track_rc_reload_state(instruction);
388-
}
389-
390-
fn track_rc_reload_state(&mut self, instruction: InstructionId) {
391-
match &self.inserter.function.dfg[instruction] {
392-
// We just had an increment or decrement to an array's reference counter
393-
Instruction::IncrementRc { .. } | Instruction::DecrementRc { .. } => {
394-
self.inside_rc_reload = true;
395-
}
396-
_ => self.inside_rc_reload = false,
397-
}
398381
}
399382

400383
fn check_array_aliasing(&self, references: &mut Block, array: ValueId) {

0 commit comments

Comments
 (0)