rustc 1.48.0+ generates branchier and less compact code for integer division w/ boundary checks #99961
Labels
A-codegen
Area: Code generation
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
regression-from-stable-to-stable
Performance or correctness regression from one stable version to another.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
The following code, which correctly bypasses overflow and divide by zero conditions, generates branchier and less optimal machine code (under x86_64) when compiled under rustc 1.48.0+ as compared to rustc 1.46.0 and below:
Godbolt comparison link
The assembly generated in 1.46.0:
vs in 1.48.0:
The astute will observe that rustc 1.47.0 was skipped in the good/bad demarcation above. That's because rustc 1.47.0 introduced an incorrect checked division w/ panic (which is now happening again). My gut feeling is that whatever fixed 1.47's dismal codegen resulted in a still-suboptimal solution as compared to what we had before.
The problem still persists in the latest nightlies, but is obscured by #99960.
@rustbot label +regression-from-stable-to-stable +A-codegen +A-llvm +T-compiler
The text was updated successfully, but these errors were encountered: