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 · 1 comment
Open

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

CAFxX opened this issue Oct 24, 2020 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@CAFxX
Copy link
Contributor

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

@randall77 randall77 added this to the Unplanned milestone Oct 24, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 26, 2020
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@cuonglm
Copy link
Member

cuonglm commented Aug 14, 2022

It seems because we rewrite Mod64 early before prove pass, so it's too late to realize the optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

5 participants