-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
[ER] A missed removal of division by zero test #86109
Comments
@rustbot label A-codegen C-enhancement I-slow +T-compiler |
Still an issue with 1.60.0-nightly (08df8b8 2022-01-30). I think this is similar to the same problem with (missed) optimizations, when we match on some variable and expect compiler to match on For provided example we can cast i16 to u16 after check, so panic go away: pub fn foo(start: T) -> T {
if start <= 0 { return 0; }
let start = start as u16; // add this to change type
let mut count = 0;
... |
Note that with rustc 1.60.0-nightly (08df8b8 2022-01-30) replacing in my original foo code the "for i in start .. 10_000 {" with an equivalent while loop is enough to remove the dividend test. |
That works for 1.54 too. |
Triage: for the example in the issue description, division by zero was present in 1.69 but disappeared in 1.70. |
Right, closed. |
Sorry, I was reviewing the PR that's adding a regression test for this, we should close this issue after the regression test lands |
…ieyouxu Add a Few Codegen Tests Closes rust-lang#86109 Closes rust-lang#64219 Those issues somehow got fixed over time. So, this PR adds a couple of codegen tests to ensure we don't regress in the future.
Rollup merge of rust-lang#132170 - veera-sivarajan:codegen-tests, r=jieyouxu Add a Few Codegen Tests Closes rust-lang#86109 Closes rust-lang#64219 Those issues somehow got fixed over time. So, this PR adds a couple of codegen tests to ensure we don't regress in the future.
This function foo:
Compiled with optimizations by rustc (1.54.0-nightly 4de7572 2021-05-01) gives:
Running the code you confirm that the divisor can't be zero.
I think Rustc should be able to remove this test.
(The same code with
T=u16
contains no division by zero test).The text was updated successfully, but these errors were encountered: