Skip to content
Snippets Groups Projects
Commit 157e4645 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'gvn_scalar_constants' into 'main'

Make GVN dedup scalar constants

See merge request !96
parents 350cee4d 05724fe0
No related branches found
No related tags found
1 merge request!96Make GVN dedup scalar constants
Pipeline #200903 passed
......@@ -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())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment