Potential Compiler Optimization Issue with &Vec<Vec<T>> vs &[Vec<T>]?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
rustc version: 1.78
See Godbolt .
In my understanding, the function that accepts &Vec<Vec> should have the same optimization as the function that accepts &[Vec], because &Vec<Vec> can be turned into &[Vec] by simply calling as_slice() or as_mut_slice().
However, I found that &Vec<Vec> may hinder further vectorization in the nested loop, as shown in the above link.
I am wondering whether this is a compiler bug or an intended action?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust snippets in the linked Godbolt comparison and reproduce them with rustc 1.78. Compare the generated code for per_pos_add_0 using &Vec<Vec> and per_pos_add_1 using &[Vec] at opt-level=2. Done means establishing whether the difference is an intended limitation or a compiler optimization bug, with a minimized reproducer if applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100