Skip to content

Commit

Permalink
chore: Remove resolve_is_unconstrained pass (#7004)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher authored Jan 9, 2025
1 parent 2abd98c commit c4512d9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 67 deletions.
1 change: 0 additions & 1 deletion compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ fn optimize_all(builder: SsaBuilder, options: &SsaEvaluatorOptions) -> Result<Ss
.run_pass(Ssa::remove_unreachable_functions, "Removing Unreachable Functions")
.run_pass(Ssa::defunctionalize, "Defunctionalization")
.run_pass(Ssa::remove_paired_rc, "Removing Paired rc_inc & rc_decs")
.run_pass(Ssa::resolve_is_unconstrained, "Resolving IsUnconstrained")
.run_pass(|ssa| ssa.inline_functions(options.inliner_aggressiveness), "Inlining (1st)")
// Run mem2reg with the CFG separated into blocks
.run_pass(Ssa::mem2reg, "Mem2Reg (1st)")
Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_evaluator/src/ssa/ir/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ impl DataFlowGraph {

/// Remove an instruction by replacing it with a `Noop` instruction.
/// Doing this avoids shifting over each instruction after this one in its block's instructions vector.
#[allow(unused)]
pub(crate) fn remove_instruction(&mut self, instruction: InstructionId) {
self.instructions[instruction] = Instruction::Noop;
self.results.insert(instruction, smallvec::SmallVec::new());
Expand Down
5 changes: 4 additions & 1 deletion compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ pub(super) fn simplify_call(
simplify_black_box_func(bb_func, arguments, dfg, block, call_stack)
}
Intrinsic::AsWitness => SimplifyResult::None,
Intrinsic::IsUnconstrained => SimplifyResult::None,
Intrinsic::IsUnconstrained => {
let result = dfg.runtime().is_brillig().into();
SimplifyResult::SimplifiedTo(dfg.make_constant(result, NumericType::bool()))
}
Intrinsic::DerivePedersenGenerators => {
if let Some(Type::Array(_, len)) = return_type.clone() {
simplify_derive_generators(dfg, arguments, len, block, call_stack)
Expand Down
16 changes: 7 additions & 9 deletions compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,6 @@ mod test {
// After EnableSideEffectsIf removal:
brillig(inline) fn main f0 {
b0(v0: Field, v1: Field, v2: u1):
v4 = call is_unconstrained() -> u1
v7 = call to_be_radix(v0, u32 256) -> [u8; 1] // `a.to_be_radix(256)`;
inc_rc v7
v8 = call to_be_radix(v0, u32 256) -> [u8; 1] // duplicate load of `a`
Expand All @@ -1574,14 +1573,13 @@ mod test {
let expected = "
brillig(inline) fn main f0 {
b0(v0: Field, v1: Field, v2: u1):
v4 = call is_unconstrained() -> u1
v7 = call to_be_radix(v0, u32 256) -> [u8; 1]
inc_rc v7
inc_rc v7
v8 = cast v2 as Field
v9 = mul v0, v8
v10 = call to_be_radix(v9, u32 256) -> [u8; 1]
inc_rc v10
v5 = call to_be_radix(v0, u32 256) -> [u8; 1]
inc_rc v5
inc_rc v5
v6 = cast v2 as Field
v7 = mul v0, v6
v8 = call to_be_radix(v7, u32 256) -> [u8; 1]
inc_rc v8
enable_side_effects v2
return
}
Expand Down
1 change: 0 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod remove_bit_shifts;
mod remove_enable_side_effects;
mod remove_if_else;
mod remove_unreachable;
mod resolve_is_unconstrained;
mod simplify_cfg;
mod unrolling;

Expand Down
55 changes: 0 additions & 55 deletions compiler/noirc_evaluator/src/ssa/opt/resolve_is_unconstrained.rs

This file was deleted.

0 comments on commit c4512d9

Please sign in to comment.