Repository navigation
Wrapper generates more instructions for simple integer operations #119520
Description
Activity
- addedC-bugCategory: This is a bug.Category: This is a bug.regression-untriagedUntriaged performance or correctness regression.Untriaged performance or correctness regression.
on Jan 2, 2024 - addedI-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingI-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.and removedregression-untriagedUntriaged performance or correctness regression.Untriaged performance or correctness regression.
on Jan 2, 2024 @rustbot modify labels: -needs-triage +A-LLVM
- addedA-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.and removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Jan 2, 2024 Possibly #100460 which modified
PartialOrd::le?WG-prioritization assigning priority (Zulip discussion).
(I wonder if it's in any way related to issue #119014 also about code generation for
Partial)@rustbot label -I-prioritize +P-medium
- addedP-mediumMedium priorityMedium priorityand removedI-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
on Jan 4, 2024 Alive2: https://alive2.llvm.org/ce/z/LDK_Rf.
(I haven't checked where the missing optimizations are.)1 remaining item
@rustbot claim
Upstream issue: llvm/llvm-project#78281
Even though I created this issue, I think there may be other solutions.
I might be able to keep the range information in the SROA, and of course for this example, I could use the LazyValueInfo calculation. When I'm sure that this is also a possible way, I'll create a new issue. (Of course, the above issue needs to be resolved as well.)But personally, I would like this issue to be solved directly in rust. I write similar code all the time (and I'm sure other projects are similar?). If we wait for an upstream solution, we may be delayed until LLVM 19. Of course, I would also like to see if I can use this to learn the MIR optimization. :)
Example of trait removal:
#![crate_type = "lib"] use std::cmp::Ordering::*; const A: i32 = 201; const B: i32 = 270; const C: i32 = 153; #[inline(never)] #[no_mangle] pub fn foo(x: i32) -> bool { matches!(x.partial_cmp(&A), Some(Greater | Equal)) && matches!(x.partial_cmp(&B), Some(Less | Equal)) || x == C }
Godbolt: https://rust.godbolt.org/z/EP9ohq5j3
Reacted by clubby789 and DaniPopes- added 2 commits that reference this issue
on Jan 23, 2024 - added a commit that references this issue
on Jan 27, 2024 - added a commit that references this issue
on Jan 27, 2024 - added a commit that references this issue
on Feb 14, 2024 - added 3 commits that reference this issue
on Feb 28, 2024 - added 2 commits that reference this issue
on Mar 8, 2024
Code
I tried this code (godbolt):
I expected to see this happen: both functions compile to identical assembly
Instead, this happened:
wrappedcontains way more instructions:Version it worked on
It most recently worked on: 1.64
Version with regression
rustc --version --verbose:I have bisected it to between 1.64 and 1.65 on Godbolt, and then further with
cargo bisect-rustcwhich points tonightly-2022-08-17(4033686...86c6ebe):Backtrace
Backtrace
@rustbot modify labels: +I-slow +regression-from-stable-to-stable -regression-untriaged