-
Notifications
You must be signed in to change notification settings - Fork 193
[msl-out] Update firstLeadingBit for signed integers #2235
Conversation
src/back/msl/writer.rs
Outdated
let s = back::vector_size_str(size); | ||
write!(self.out, "{NAMESPACE}::select(int{s}(")?; | ||
write!(self.out, "{NAMESPACE}::floor(")?; | ||
write!(self.out, "{NAMESPACE}::log2(float{s}(")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect using a floating-point logarithm here to be much slower than using metal::clz
. Could you see if that can work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah small oversight on my part, I can fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'm just going to rename something, and then I'll squash and merge this.
Because I added a commit renaming a variable, GitHub stuck that "Co-authored" comment in there and I didn't notice it - but for the record, this PR is entirely @evahop's work. (Force-pushing to master is a pain for others, and we've got it disabled.) |
Update
firstLeadingBit
to return-1
when input is0
or-1
,and return the index of the first set
0
bit for all other negative values.