Removing LLVM blockers for Rust compiler
High Priority bugs in LLVM for the Rust compiler indicates that we need to ask Huawei's help to resolve these problems.
At the following thread a heated discussion has revealed 5-10 issues that need to be addressed.
List of features as candidates for Huawei's LLVM team
A lot of these have examples on godbolt. Add --emit llvm-ir to the flags to
show the LLVM IR that rustc is generating.
Rust insufficiently optimizes loop { match { } } state machines
rust-lang/rust#80630
align_to prefix max length not taken into account in optimization
Unnecessary auto-vectorization ie emitted when the max length of a loop is always less than 16.
rust-lang/rust#72356
Comparison of Option<NonZeroU*> is not fully optimized
rust-lang/rust#49892
cmov conversion hurts binary search performance
rust-lang/rust#53823
https://bugs.llvm.org/show_bug.cgi?id=40027
&& operator chains (and ||, possibly) generates unoptimizable LLVM IR
rust-lang/rust#83623
https://bugs.llvm.org/show_bug.cgi?id=51211
rust can't serialize 11 fields efficiently
https://rust.godbolt.org/z/hfG734fGf
rust-lang/rust#45068
Compiler generating extra memcpy, inconsistently depending on used types
rust-lang/rust#85094
https://godbolt.org/z/d5PKx3b1d
Different (suboptimal) assembly generated for match expr vs if-else ifs
rust-lang/rust#100562
Rust 1.56.0+ no longer recognizes boundary checks as avoiding division overflow panic
rust-lang/rust#99960
https://godbolt.org/z/x95rGbW4j
Suboptimal codegen for snippet with Armv7 target
rust-lang/rust#98157
https://godbolt.org/z/ehxabaq38
Inefficient compilation of ? operator
rust-lang/rust#88616
This comment shows a simple example of this issue:
rust-lang/rust#88616 (comment)
NonZero prevents values from being const-propagated properly
Specifically the example in this comment is not being optimized.
rust-lang/rust#51346 (comment)
See the godbolt examples here:
https://godbolt.org/z/fPjn9zxo6
SimplifyCFG doesn't preserve information about exhaustive switch
The example LLVM IR that fails to optimize is in this comment:
rust-lang/rust#85133 (comment)