Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion compiler/noirc_evaluator/src/ssa/ir/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ pub(crate) struct GlobalsGraph {
/// All of the instructions in the global value space.
/// These are expected to all be Instruction::MakeArray
instructions: DenseMap<Instruction>,

#[serde(skip)]
constants: HashMap<(FieldElement, NumericType), ValueId>,
}

impl GlobalsGraph {
pub(crate) fn from_dfg(dfg: DataFlowGraph) -> Self {
Self { values: dfg.values, instructions: dfg.instructions }
Self { values: dfg.values, instructions: dfg.instructions, constants: dfg.constants }
}

/// Iterate over every Value in this DFG in no particular order, including unused Values
Expand Down Expand Up @@ -386,6 +389,9 @@ impl DataFlowGraph {
if let Some(id) = self.constants.get(&(constant, typ)) {
return *id;
}
if let Some(id) = self.globals.constants.get(&(constant, typ)) {
return *id;
}
let id = self.values.insert(Value::NumericConstant { constant, typ });
self.constants.insert((constant, typ), id);
id
Expand Down
Loading