[all-commits] [llvm/llvm-project] 6d2093: [CodeGenPrepare] Delete intrinsic call to llvm.ass...
weiguozhi via All-commits
all-commits at lists.llvm.org
Tue Mar 31 11:57:45 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 6d20937c29a1a1d67fc5e8caf8538b4aa5614505
https://github.com/llvm/llvm-project/commit/6d20937c29a1a1d67fc5e8caf8538b4aa5614505
Author: Guozhi Wei <carrot at google.com>
Date: 2020-03-31 (Tue, 31 Mar 2020)
Changed paths:
M llvm/lib/CodeGen/CodeGenPrepare.cpp
M llvm/test/Transforms/CodeGenPrepare/X86/extend-sink-hoist.ll
M llvm/test/Transforms/CodeGenPrepare/X86/optimizeSelect-DT.ll
A llvm/test/Transforms/CodeGenPrepare/X86/tailcall-assume-xbb.ll
Log Message:
-----------
[CodeGenPrepare] Delete intrinsic call to llvm.assume to enable more tailcall
The attached test case is simplified from tcmalloc. Both function calls should be optimized as tailcall. But llvm can only optimize the first call. The second call can't be optimized because function dupRetToEnableTailCallOpts failed to duplicate ret into block case2.
There 2 problems blocked the duplication:
1 Intrinsic call llvm.assume is not handled by dupRetToEnableTailCallOpts.
2 The control flow is more complex than expected, dupRetToEnableTailCallOpts can only duplicate ret into its predecessor, but here we have an intermediate block between call and ret.
The solutions:
1 Since CodeGenPrepare is already at the end of LLVM IR phase, we can simply delete the intrinsic call to llvm.assume.
2 A general solution to the complex control flow is hard, but for this case, after exit2 is duplicated into case1, exit2 is the only successor of exit1 and exit1 is the only predecessor of exit2, so they can be combined through eliminateFallThrough. But this function is called too late, there is no more dupRetToEnableTailCallOpts after it. We can add an earlier call to eliminateFallThrough to solve it.
Differential Revision: https://reviews.llvm.org/D76539
More information about the All-commits
mailing list