Re:Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Ca...
by haberman on Sunday April 25, 2021 @01:38PM
(#26934642)
Wow thanks for the pointer! That seems unfortunate, I wonder if there is a way to evaluate whether the extra jump is actually worth it, and whether this optimization could be allowed.
Re:Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Ca...
by chandlerc1024 on Sunday April 25, 2021 @07:09PM
(#26937585)
At the very least, can check when the target isn't a basic block and thus it's a clear win. Will fix your case.
I'm dubious about the whole thing though. Seems like it may day from when branching "down" vs. "up" mattered to branch prediction.
Re:Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Ca...
by pyler on Sunday April 25, 2021 @07:55PM
(#26937892)
It seems that that code handles just the case when target is function.
https://github.com/llvm/llvm-project/blob/535df472b04208d6ae...
Re:Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Ca...
by ndesaulniers on Monday April 26, 2021 @07:43PM
(#26949757)
commit a468601e0ead ("[X86] Re-enable conditional tail calls and fix PR31257.")
https://reviews.llvm.org/D29856
added the comment.
If I remove the check for `OptForSize` and `PredTBB == MBB`, we can optimize OP's report, but seem to regress basic tests like llvm/test/CodeGen/X86/conditional-tailcall.ll, literally flipping the branches incorrectly IIUC.
Re:Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Ca...
by ndesaulniers on Sunday April 25, 2021 @05:06PM
(#26936689)
Nice find! I wonder what they mean by changing branch direction?
Re:Parsing Protobuf at 2+GB/S: How I Learned to Love Tail Ca...
by andreareina on Monday April 26, 2021 @01:38AM
(#26939546)
Why is that a problem? I'd figure that a short jump is basically free since the target is likely to be in the instruction cache? Is it an issue of readahead/speculation through multiple jumps?
Check line 1521
https://llvm.org/doxygen/BranchFolding_8cpp_source.html