Skip to content
Snippets Groups Projects

Make GVN dedup scalar constants

Merged rarbore2 requested to merge gvn_scalar_constants into main
1 file
+ 4
1
Compare changes
  • Side-by-side
  • Inline
+ 4
1
@@ -31,7 +31,10 @@ pub fn gvn(editor: &mut FunctionEditor, gvn_constants_and_clones: bool) {
// Also, don't GVN constants and clones if indicated to not do so.
if *number == work
|| (!gvn_constants_and_clones
&& (editor.func().nodes[work.idx()].is_constant()
&& (editor.func().nodes[work.idx()]
.try_constant()
.map(|cons_id| !editor.get_constant(cons_id).is_scalar())
.unwrap_or(false)
|| editor.func().nodes[work.idx()]
.try_write()
.map(|(_, _, indices)| indices.is_empty())
Loading