Skip to content

cmd/compile: unneeded panicshift for bounded shift amount #42179

@CAFxX

Description

@CAFxX

Tested on 1.15.3 and tip.

Foo contains an unnecessary panicshift call, whereas Bar does not:

func Foo(x int) byte {
    if x >= 0 { 
        return byte(1) << (x % 8)
    }
    return 0
}

func Bar(x uint) byte {
    return byte(1) << (x % 8)
}

godbolt link: https://godbolt.org/z/qhTqYM

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions