From 954339eb600b7043807a4c622c5efee1599b1eb6 Mon Sep 17 00:00:00 2001 From: Russel Arbore <russel.jma@gmail.com> Date: Wed, 5 Feb 2025 16:12:52 -0600 Subject: [PATCH] Do DC subst in float-collections --- hercules_opt/src/float_collections.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hercules_opt/src/float_collections.rs b/hercules_opt/src/float_collections.rs index 6ef050c2..d64b3f80 100644 --- a/hercules_opt/src/float_collections.rs +++ b/hercules_opt/src/float_collections.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; use hercules_ir::*; @@ -83,10 +83,6 @@ pub fn float_collections( .map(|(idx, node)| (NodeID::new(idx), node.clone())) .collect(); let success = editors.get_mut(&caller).unwrap().edit(|mut edit| { - let cons_ids: Vec<_> = cons - .iter() - .map(|(_, node)| edit.add_node(node.clone())) - .collect(); for (id, node) in calls { let Node::Call { control, @@ -97,6 +93,19 @@ pub fn float_collections( else { panic!() }; + let dc_args = (0..dynamic_constants.len()) + .map(|i| edit.add_dynamic_constant(DynamicConstant::Parameter(i))); + let substs = dc_args + .zip(dynamic_constants.iter().map(|id| *id)) + .collect::<HashMap<_, _>>(); + let cons_ids: Vec<_> = cons + .iter() + .map(|(_, node)| { + let mut node = node.clone(); + substitute_dynamic_constants_in_node(&substs, &mut node, &mut edit); + edit.add_node(node) + }) + .collect(); let mut args = Vec::from(args); args.extend(cons_ids.iter()); let new_call = edit.add_node(Node::Call { -- GitLab