2013-03-13 00:27:52 +08:00
|
|
|
; REQUIRES: asserts
|
2003-09-20 13:02:54 +08:00
|
|
|
; This function contains two tail calls, which should be eliminated
|
[TailCallElim] Preserve DT and PDT
Summary:
Previously, in the NewPM pipeline, TailCallElim recalculates the DomTree when it modifies any instruction in the Function.
For example,
```
CallInst *CI = dyn_cast<CallInst>(&I);
...
CI->setTailCall();
Modified = true;
...
if (!Modified || ...)
return PreservedAnalyses::all();
```
After applying this patch, the DomTree only recalculates if needed (plus an extra insertEdge() + an extra deleteEdge() call).
When optimizing SQLite with `-passes="default<O3>"` pipeline of the newPM, the number of DomTree recalculation decreases by 6.2%, the number of nodes visited by DFS decreases by 2.9%. The time used by DomTree will decrease approximately 1%~2.5% after applying the patch.
Statistics:
```
Before the patch:
23010 dom-tree-stats - Number of DomTree recalculations
489264 dom-tree-stats - Number of nodes visited by DFS -- DomTree
After the patch:
21581 dom-tree-stats - Number of DomTree recalculations
475088 dom-tree-stats - Number of nodes visited by DFS -- DomTree
```
Reviewers: kuhar, dmgreen, brzycki, grosser, davide
Reviewed By: kuhar, brzycki
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49982
llvm-svn: 338954
2018-08-04 16:13:47 +08:00
|
|
|
; RUN: opt < %s -tailcallelim -verify-dom-info -stats -disable-output 2>&1 | grep "2 tailcallelim"
|
2003-09-20 13:02:54 +08:00
|
|
|
|
2008-03-10 15:21:50 +08:00
|
|
|
define i32 @Ack(i32 %M.1, i32 %N.1) {
|
2003-09-20 13:02:54 +08:00
|
|
|
entry:
|
2008-03-10 15:21:50 +08:00
|
|
|
%tmp.1 = icmp eq i32 %M.1, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %tmp.1, label %then.0, label %endif.0
|
|
|
|
then.0: ; preds = %entry
|
|
|
|
%tmp.4 = add i32 %N.1, 1 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.4
|
|
|
|
endif.0: ; preds = %entry
|
|
|
|
%tmp.6 = icmp eq i32 %N.1, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %tmp.6, label %then.1, label %endif.1
|
|
|
|
then.1: ; preds = %endif.0
|
|
|
|
%tmp.10 = add i32 %M.1, -1 ; <i32> [#uses=1]
|
|
|
|
%tmp.8 = call i32 @Ack( i32 %tmp.10, i32 1 ) ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.8
|
|
|
|
endif.1: ; preds = %endif.0
|
|
|
|
%tmp.13 = add i32 %M.1, -1 ; <i32> [#uses=1]
|
|
|
|
%tmp.17 = add i32 %N.1, -1 ; <i32> [#uses=1]
|
|
|
|
%tmp.14 = call i32 @Ack( i32 %M.1, i32 %tmp.17 ) ; <i32> [#uses=1]
|
|
|
|
%tmp.11 = call i32 @Ack( i32 %tmp.13, i32 %tmp.14 ) ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.11
|
2003-09-20 13:02:54 +08:00
|
|
|
}
|
|
|
|
|