Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[msl-out] Update firstLeadingBit for signed integers #2235

Merged
merged 9 commits into from
Feb 2, 2023

Conversation

evahop
Copy link
Contributor

@evahop evahop commented Feb 1, 2023

Update firstLeadingBit to return -1 when input is 0 or -1,
and return the index of the first set 0 bit for all other negative values.

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}(")?;
Copy link
Member

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?

Copy link
Contributor Author

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.

src/back/msl/writer.rs Outdated Show resolved Hide resolved
src/back/msl/writer.rs Outdated Show resolved Hide resolved
Copy link
Member

@jimblandy jimblandy left a 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.

src/back/msl/writer.rs Outdated Show resolved Hide resolved
@jimblandy jimblandy merged commit fb2d438 into gfx-rs:master Feb 2, 2023
@jimblandy
Copy link
Member

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.)

@evahop evahop deleted the msl-flb branch February 2, 2023 21:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants