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

Regression in debug codegen for simple division #111663

Open
carbotaniuman opened this issue May 16, 2023 · 1 comment
Open

Regression in debug codegen for simple division #111663

carbotaniuman opened this issue May 16, 2023 · 1 comment
Labels
C-bug Category: This is a bug. I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@carbotaniuman
Copy link
Contributor

I tried this code:

pub fn num_pages(alloc: i32) -> i32 {
    num / 4096
}

I expected to see this happen: There not to be any excess code or panics for a simple division.

Instead, this happened: In 1.69, there are no panics of any kind, and rustc simply generates the division as it should. In the current nightly, rustc generates a panic call. I go through a lot of care in this code to only use raw pointers and such to avoid overhead for debug mode performance, and yet this constant division still exists. There's also no unchecked_div, so I can't even use unsafe to get out of this.

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (2c41369ac 2023-05-13)
binary: rustc
commit-hash: 2c41369acc445d04129db40ba998dd7a89fb0d2e
commit-date: 2023-05-13
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2
Compiler returned: 0
@carbotaniuman carbotaniuman added the C-bug Category: This is a bug. label May 16, 2023
@saethlin
Copy link
Member

See #109900 (comment)

@jyn514 jyn514 added the I-slow Issue: Problems and improvements with respect to performance of generated code. label May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

3 participants