Skip to content

remove_if_else: slice dummy data might not be needed #9922

@asterite

Description

@asterite

Problem

When remove_if_else has to merge two slices that potentially have different lengths, the result if a slice that has the maximum length of both. For example if we merge [v0, v1] with [v2, v3, v4] we get a slice of length 3. For the first two elements we'll merge v0 with v2, then v1 with v3. For the last element we'll merge v4 with a dummy value (zero).

The dummy value will never be accessed because when accessing a slice we always check that the index is in bounds (the actual length is merged and tracked separately).

Given that the dummy value will never be accessed, we could directly use v4 as the last element. Then merging a dummy value with v4 is not needed, leading to less SSA code and maybe optimized performance.

Happy Case

Dummy values for slices are never used.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditPreparation or execution of security code audits.ssa

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions