Different ways of writing Option::or
codegen differently
#124533
Labels
A-codegen
Area: Code generation
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Copying this here from #101210 (comment) cc @veber-alex
Demo: https://rust.godbolt.org/z/96W4h87Yn
The currently-optimized form isn't allowed to be transformed into the better one: https://alive2.llvm.org/ce/z/DXXRPX
A couple thoughts on things that might help in the codegen:
noundef
(this will hopefully be addressed by Array-as-Immediate array ABI is missingnoundef
parameter metadata #123183 )!range
metadata (https://rust.godbolt.org/z/KKTKTa1qs), we're hitting the classic problem of us emittingAnd LLVM forgetting both different ways that we told it that inputs like
0x00_05
(the one Alive found) are UB.Maybe us emitting
trunc nuw
will be the eventual solution here? If thetrunc nuw
+zext
could fold to justzext
rather thanand
+zext
maybe it'd be enough...Adding some assumes does give LLVM enough information to be allowed to optimize again (https://alive2.llvm.org/ce/z/e6NWxA) though seemingly it doesn't from that starting point
The text was updated successfully, but these errors were encountered: