Skip to content

Commit

Permalink
chore: Remove unused Intrinsic::Println (#2358)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan-000 authored Aug 17, 2023
1 parent c964ee8 commit 98d3cf7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 50 deletions.
2 changes: 0 additions & 2 deletions crates/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,6 @@ impl Context {

self.acir_context.bit_decompose(endian, field, bit_size, result_type)
}
// TODO(#2115): Remove the println intrinsic as the oracle println is now used instead
Intrinsic::Println => Ok(Vec::new()),
Intrinsic::Sort => {
let inputs = vecmap(arguments, |arg| self.convert_value(*arg, dfg));
// We flatten the inputs and retrieve the bit_size of the elements
Expand Down
5 changes: 1 addition & 4 deletions crates/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub(crate) enum Intrinsic {
SliceInsert,
SliceRemove,
StrAsBytes,
Println,
ToBits(Endian),
ToRadix(Endian),
BlackBox(BlackBoxFunc),
Expand All @@ -50,7 +49,6 @@ pub(crate) enum Intrinsic {
impl std::fmt::Display for Intrinsic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Intrinsic::Println => write!(f, "println"),
Intrinsic::Sort => write!(f, "arraysort"),
Intrinsic::ArrayLen => write!(f, "array_len"),
Intrinsic::AssertConstant => write!(f, "assert_constant"),
Expand All @@ -76,7 +74,7 @@ impl Intrinsic {
/// If there are no side effects then the `Intrinsic` can be removed if the result is unused.
pub(crate) fn has_side_effects(&self) -> bool {
match self {
Intrinsic::Println | Intrinsic::AssertConstant => true,
Intrinsic::AssertConstant => true,

Intrinsic::Sort
| Intrinsic::ArrayLen
Expand All @@ -99,7 +97,6 @@ impl Intrinsic {
/// If there is no such intrinsic by that name, None is returned.
pub(crate) fn lookup(name: &str) -> Option<Intrinsic> {
match name {
"println" => Some(Intrinsic::Println),
"arraysort" => Some(Intrinsic::Sort),
"array_len" => Some(Intrinsic::ArrayLen),
"assert_constant" => Some(Intrinsic::AssertConstant),
Expand Down
1 change: 0 additions & 1 deletion crates/noirc_evaluator/src/ssa/ir/instruction/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ pub(super) fn simplify_call(
}
Intrinsic::BlackBox(bb_func) => simplify_black_box_func(bb_func, arguments, dfg),
Intrinsic::Sort => simplify_sort(dfg, arguments),
Intrinsic::Println => SimplifyResult::None,
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/noirc_evaluator/src/ssa/opt/die.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod test {
// v9 = add v7, Field 2
// v10 = add v7, Field 3
// v11 = add v10, v10
// call println(v8)
// call assert_constant(v8)
// return v9
// }
let main_id = Id::test_new(0);
Expand Down Expand Up @@ -187,8 +187,8 @@ mod test {
let v10 = builder.insert_binary(v7, BinaryOp::Add, three);
let _v11 = builder.insert_binary(v10, BinaryOp::Add, v10);

let println_id = builder.import_intrinsic_id(Intrinsic::Println);
builder.insert_call(println_id, vec![v8], vec![]);
let assert_constant_id = builder.import_intrinsic_id(Intrinsic::AssertConstant);
builder.insert_call(assert_constant_id, vec![v8], vec![]);
builder.terminate_with_return(vec![v9]);

let ssa = builder.finish();
Expand All @@ -210,7 +210,7 @@ mod test {
// v7 = load v6
// v8 = add v7, Field 1
// v9 = add v7, Field 2
// call println(v8)
// call assert_constant(v8)
// return v9
// }
let ssa = ssa.dead_instruction_elimination();
Expand Down
70 changes: 36 additions & 34 deletions crates/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,8 @@ mod test {
// will store values. Other blocks do not store values so that we can test
// how these existing values are merged at each join point.
//
// For debugging purposes, each block also has a call to println with two
// arguments. The first is the block the println was originally in, and the
// For debugging purposes, each block also has a call to test_function with two
// arguments. The first is the block the test_function was originally in, and the
// second is the current value stored in the reference.
//
// b0 (0 stored)
Expand Down Expand Up @@ -1040,54 +1040,56 @@ mod test {
builder.insert_store(r1, value);
};

let println = builder.import_intrinsic_id(Intrinsic::Println);
let test_function = Id::test_new(1);

let call_println = |builder: &mut FunctionBuilder, block: u128| {
let call_test_function = |builder: &mut FunctionBuilder, block: u128| {
let block = builder.field_constant(block);
let load = builder.insert_load(r1, Type::field());
builder.insert_call(println, vec![block, load], Vec::new());
builder.insert_call(test_function, vec![block, load], Vec::new());
};

let switch_store_and_print = |builder: &mut FunctionBuilder, block, block_number: u128| {
builder.switch_to_block(block);
store_value(builder, block_number);
call_println(builder, block_number);
};
let switch_store_and_test_function =
|builder: &mut FunctionBuilder, block, block_number: u128| {
builder.switch_to_block(block);
store_value(builder, block_number);
call_test_function(builder, block_number);
};

let switch_and_print = |builder: &mut FunctionBuilder, block, block_number: u128| {
builder.switch_to_block(block);
call_println(builder, block_number);
};
let switch_and_test_function =
|builder: &mut FunctionBuilder, block, block_number: u128| {
builder.switch_to_block(block);
call_test_function(builder, block_number);
};

store_value(&mut builder, 0);
call_println(&mut builder, 0);
call_test_function(&mut builder, 0);
builder.terminate_with_jmp(b1, vec![]);

switch_store_and_print(&mut builder, b1, 1);
switch_store_and_test_function(&mut builder, b1, 1);
builder.terminate_with_jmpif(c1, b2, b3);

switch_store_and_print(&mut builder, b2, 2);
switch_store_and_test_function(&mut builder, b2, 2);
builder.terminate_with_jmp(b4, vec![]);

switch_store_and_print(&mut builder, b3, 3);
switch_store_and_test_function(&mut builder, b3, 3);
builder.terminate_with_jmp(b8, vec![]);

switch_and_print(&mut builder, b4, 4);
switch_and_test_function(&mut builder, b4, 4);
builder.terminate_with_jmpif(c4, b5, b6);

switch_store_and_print(&mut builder, b5, 5);
switch_store_and_test_function(&mut builder, b5, 5);
builder.terminate_with_jmp(b7, vec![]);

switch_store_and_print(&mut builder, b6, 6);
switch_store_and_test_function(&mut builder, b6, 6);
builder.terminate_with_jmp(b7, vec![]);

switch_and_print(&mut builder, b7, 7);
switch_and_test_function(&mut builder, b7, 7);
builder.terminate_with_jmp(b9, vec![]);

switch_and_print(&mut builder, b8, 8);
switch_and_test_function(&mut builder, b8, 8);
builder.terminate_with_jmp(b9, vec![]);

switch_and_print(&mut builder, b9, 9);
switch_and_test_function(&mut builder, b9, 9);
let load = builder.insert_load(r1, Type::field());
builder.terminate_with_return(vec![load]);

Expand All @@ -1097,39 +1099,39 @@ mod test {
//
// fn main f0 {
// b0(v0: u1, v1: u1):
// call println(Field 0, Field 0)
// call println(Field 1, Field 1)
// call test_function(Field 0, Field 0)
// call test_function(Field 1, Field 1)
// enable_side_effects v0
// call println(Field 2, Field 2)
// call println(Field 4, Field 2)
// call test_function(Field 2, Field 2)
// call test_function(Field 4, Field 2)
// v29 = and v0, v1
// enable_side_effects v29
// call println(Field 5, Field 5)
// call test_function(Field 5, Field 5)
// v32 = not v1
// v33 = and v0, v32
// enable_side_effects v33
// call println(Field 6, Field 6)
// call test_function(Field 6, Field 6)
// enable_side_effects v0
// v36 = mul v1, Field 5
// v37 = mul v32, Field 2
// v38 = add v36, v37
// v39 = mul v1, Field 5
// v40 = mul v32, Field 6
// v41 = add v39, v40
// call println(Field 7, v42)
// call test_function(Field 7, v42)
// v43 = not v0
// enable_side_effects v43
// store Field 3 at v2
// call println(Field 3, Field 3)
// call println(Field 8, Field 3)
// call test_function(Field 3, Field 3)
// call test_function(Field 8, Field 3)
// enable_side_effects Field 1
// v47 = mul v0, v41
// v48 = mul v43, Field 1
// v49 = add v47, v48
// v50 = mul v0, v44
// v51 = mul v43, Field 3
// v52 = add v50, v51
// call println(Field 9, v53)
// call test_function(Field 9, v53)
// return v54
// }

Expand Down
8 changes: 4 additions & 4 deletions crates/noirc_evaluator/src/ssa/opt/inlining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ mod test {
// fn main f0 {
// b0(v0: u1):
// v2 = call f1(v0)
// call println(v2)
// call assert_constant(v2)
// return
// }
// fn inner1 f1 {
Expand All @@ -746,8 +746,8 @@ mod test {
let inner1_id = Id::test_new(1);
let inner1 = builder.import_function(inner1_id);
let main_v2 = builder.insert_call(inner1, vec![main_cond], vec![Type::field()])[0];
let println = builder.import_intrinsic_id(Intrinsic::Println);
builder.insert_call(println, vec![main_v2], vec![]);
let assert_constant = builder.import_intrinsic_id(Intrinsic::AssertConstant);
builder.insert_call(assert_constant, vec![main_v2], vec![]);
builder.terminate_with_return(vec![]);

builder.new_function("inner1".into(), inner1_id);
Expand Down Expand Up @@ -781,7 +781,7 @@ mod test {
// b1():
// jmp b3(Field 1)
// b3(v3: Field):
// call println(v3)
// call assert_constant(v3)
// return
// b2():
// jmp b3(Field 2)
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ mod tests {
let one = builder.field_constant(FieldElement::one());
builder.insert_store(v0, one);
let v1 = builder.insert_load(v0, Type::field());
let f0 = builder.import_intrinsic_id(Intrinsic::Println);
let f0 = builder.import_intrinsic_id(Intrinsic::AssertConstant);
builder.insert_call(f0, vec![v0], vec![]);
builder.terminate_with_return(vec![v1]);

Expand Down

0 comments on commit 98d3cf7

Please sign in to comment.