Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handling for negated conditions when folding IfElse instructions. #6878

Open
TomAFrench opened this issue Dec 19, 2024 · 0 comments · May be fixed by #6888
Open

Add handling for negated conditions when folding IfElse instructions. #6878

TomAFrench opened this issue Dec 19, 2024 · 0 comments · May be fixed by #6888

Comments

@TomAFrench
Copy link
Member

In #6875 we added an optimisation such that we'd flatten the below nested if statement such that it became the simple if-statement below.

// Let then_condition_1 == then_condition_2

if then_condition_1 {
   then_value_1
} else if else_condition_1 {
   if then_condition_2 {
     then_value_1
   } else if else_condition_2 {
     else_value
   }
}

// Propagate conditions such that

if then_condition {
   then_value_1
} else if else_condition_1 {
     else_value
}

In theory we could perform a similar simplification for the case below:

Let then_condition_1 == else_condition_2

if then_condition_1 {
   then_value_1
} else if else_condition_1 {
   if then_condition_2 {
     then_value_1
   } else if else_condition_2 {
     else_value
   }
}

// Propagate conditions such that

if then_condition {
   then_value_1
} else if else_condition_1 {
    then_value_1
}

This is hindered by the fact that the else_conditions for if-else instructions in Noir's SSA are constructed on the fly so that they're very unlikely to share a valueid with a different value in the circuit. When we make this more reliable we can enable this optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

1 participant