Skip to content

Merge default case with other adjacent fall-through cases #10376

Description

@niloc132

Input source: https://github.com/geogebra/geogebra/blob/3618a4ad1d341d8d155c866e320a223ed2687249/source/shared/common/src/main/java/org/geogebra/common/main/settings/AlgebraStyle.java#L102-L111

Apparently, app.isDesktop() compiles to false, and app.isHTML5Applet() compiles to true. This results in the entire method compiling out as

function Jjj(a) {
    switch (a.A) {
        case 0:
            return !1;
        case 5:
        default:
        case 4:
            return !0;
    }
}

I'm not presently aware of which pass is removing the duplicate return false statements, or why the cases are reordered, but if we removed the case statements that fall through with the default, the existing DCE "only two branches in a switch" optimization would be capable of rewriting to

function Jjj(n) {
    return n.A != 0;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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