Skip to content

Conversation

@EFanZh
Copy link
Contributor

@EFanZh EFanZh commented Jan 1, 2024

I noticed that the values returned by NonZero*::get functions are not considered non-zero by the compiler, which could lead to bad code generation: https://godbolt.org/z/1Wcb9Po9f. This PR asserts the returned values being non-zero, which could improve code generation in certain situations, one of which being divide an integer by the sum of two smaller non-zero integers: https://godbolt.org/z/sa64xzeec.

@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2024

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 1, 2024
@EFanZh EFanZh changed the title Assert the value returned NonZero*::get being non-zero Assert the value returned by NonZero*::get being non-zero Jan 1, 2024
@Noratrieb
Copy link
Member

this is already being done in #119452

@Mark-Simulacrum
Copy link
Member

Going to go ahead and close in favor of that PR. Thanks!

@EFanZh EFanZh deleted the non-zero-hint branch October 3, 2024 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants