Skip to content

Destructuring a tuple emits inc_rc instructions for all arrays even if assigned to _ #11403

@TomAFrench

Description

@TomAFrench

Consider the below program

unconstrained fn main(b: ([Field; 2], Field)) {
    let (_, _) = b;
}

We destructure b but immediately discard the destructured internals so this is a noop. We would then expect this program to be completely empty.

The initial SSA generated however is the below

After Initial SSA:
brillig(inline) fn main f0 {
  b0(v0: [Field; 2], v1: Field):
    inc_rc v0
    return
}

We're then unnecessarily increasing the reference counter for v0 such that we'll never benefit from the optimisations from the case where rc == 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions