-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.WG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generation
Description
pub fn test_saturating(a: u32) -> u32 {
a.saturating_add(7).saturating_add(13)
}
gets compiled to
playground::test_saturating:
add edi, 7
mov eax, -1
cmovb edi, eax
add edi, 13
cmovae eax, edi
ret
but ideally it would get compiled to a.saturating_add(20)
, aka
playground::test_saturating:
add edi, 20
mov eax, -1
cmovae eax, edi
ret
Ditto for checked_add.
Playground repro: https://play.rust-lang.org/?gist=eeea31ea85491e38bdd6d456b9f6e47f&version=nightly&mode=release&edition=2015
Found looking at step_by, which would like .next(); .nth(step)
to collapse nicely for ranges (#52065).
canonbrother
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.WG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generation