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

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

Open
CAFxX opened this issue Oct 24, 2020 · 0 comments
Open

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

CAFxX opened this issue Oct 24, 2020 · 0 comments

Comments

@CAFxX
Copy link
Contributor

@CAFxX CAFxX commented Oct 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants