missed optimization on basic loops
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- compilers, performance
Línea de trabajo
Reproduce fill_one_fold and fill_one_loop in the linked Compiler Explorer link, then compare generated setup, remainder-handling, and loop instructions at -Copt-level=3 and -Copt-level=z. The relevant entry points are the two Rust functions and their LLVM IR. Done means the ordinary loop receives comparable or better codegen without relying on the fold formulation.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Surprisingly, the fold variant below generates (slightly) better code
https://godbolt.org/z/78G5W3MWf
#[unsafe(no_mangle)]
pub fn fill_one_fold(a: &mut [u32]) {
a.iter_mut().fold((), |(), x| *x = 1);
}
#[unsafe(no_mangle)]
pub fn fill_one_loop(a: &mut [u32]) {
for e in a.iter_mut() {
*e = 1;
}
}
At opt level 3 the main loop is the same, so for raw performance it won't matter much
.LBB1_3:
movups xmmword ptr [rdi + 4*r8], xmm0
movups xmmword ptr [rdi + 4*r8 + 16], xmm0
add r8, 8
cmp rdx, r8
jne .LBB1_3
But the setup code and handling the remainder (that does not fit in a vector register is worse. The total size is 28 versus 24 instructions.
When using -Copt-level=z, the main loop is actually worse by one instruction
.LBB0_2:
mov dword ptr [rdi + 4*rax], 1
inc rax
cmp rsi, rax
jne .LBB0_2
versus
.LBB1_1:
cmp rsi, rax
je .LBB1_3
mov dword ptr [rdi + rax], 1
add rax, 4
jmp .LBB1_1
What is worrying really is that a fairly basic loop is not handled optimally by LLVM.
- Lenguaje dominante
- Rust
- Estrellas
- 123k
- Forks
- 16.6k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 532
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/rust
-
strictly_dominates missing a `=`AbiertoC-bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
rust-lang/rust#166722 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A-run-make C-bug T-bootstrap
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`Abiertorelnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
Todos los issues de rust-lang/rust
Issues similares
-
bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug core-lang
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Windows microphone listing treats words in a device name as DirectShow labelsPosiblemente ocupada @Sujal-chaudhary la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
clipy-recorder/clipy#447 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
nightly-cleanup
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
max-sixty/worktrunk#4939 · 1 reacción ·
Los mantenedores suelen responder en 1 día