TIL about rustc/LLVM: 1) rustc apparently doesn't automatically combine identical match arms. 2) Combining three consecutive identical match arms can cause the combined case check to be reordered relative to the other match arm checks making unlucky code slower.
-
Show this thread
-
I guess there's no way to tell the compiler about the relative probability of the match arms. Evidently, the source order of the match arms is not it. :-(
2 replies 1 retweet 0 likesShow this thread -
Replying to @hsivonen
/me wonders if https://doc.rust-lang.org/std/intrinsics/fn.likely.html … is a likely suspect for extension for this case...
1 reply 0 retweets 0 likes -
Replying to @larsberg_
Apparently not with it its current mapping to LLVM IR, but maybe there's a different LLVM feature that could work.
1 reply 0 retweets 1 like -
Replying to @hsivonen @larsberg_
Could rustc optimize the matches in MIR before they hit LLVM IR?
1 reply 0 retweets 0 likes
It probably should. The reason why LLVM doesn’t combine identical basic blocks, as I understand it, is compile time.
9:56 AM - 4 Jan 2018
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.