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: ctz rules on s390x #19551

randall77 opened this issue Mar 14, 2017 · 2 comments


None yet
3 participants
Copy link

commented Mar 14, 2017

I don't think these rules do the right thing if the input argument is 0.
What does FLOGR return if the input is 0?
Ctz64 should return 64 if the input is 0, and Ctz32 should return 32 if the input is 0. But FLOGR is used for both, one of them at least has to be wrong.

It probably doesn't matter at the moment as the runtime probably never calls Ctz with a 0 argument. But I'm about to make math/bits use the intrinsic, and there it matters.


@randall77 randall77 added this to the Go1.9 milestone Mar 14, 2017


This comment has been minimized.

Copy link

commented Mar 15, 2017

I can see why the rules looks dubious but they are correct. I've created a little program to demonstrate:

Thanks for opening the issue though, always worth double checking these things :).


This comment has been minimized.

Copy link
Contributor Author

commented Mar 16, 2017

Ok, I was confused about the bit twiddling. (CtzX 0) doesn't actually pass 0 to FLOGR.
Thanks for looking into it.

@randall77 randall77 closed this Mar 16, 2017

@golang golang locked and limited conversation to collaborators Mar 16, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.