Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swiftshader
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
swiftshader
Commits
f49b2396
Commit
f49b2396
authored
Nov 09, 2015
by
Jim Stichnoth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subzero: Recognize single-block loops during loop depth analysis.
BUG= none R=jpp@chromium.org Review URL:
https://codereview.chromium.org/1416113007
.
parent
e39d0ca2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
IceLoopAnalyzer.cpp
src/IceLoopAnalyzer.cpp
+10
-0
IceLoopAnalyzer.h
src/IceLoopAnalyzer.h
+1
-0
loop-nest-depth.ll
tests_lit/llvm2ice_tests/loop-nest-depth.ll
+25
-0
No files found.
src/IceLoopAnalyzer.cpp
View file @
f49b2396
...
@@ -34,6 +34,14 @@ void LoopAnalyzer::LoopNode::incrementLoopNestDepth() {
...
@@ -34,6 +34,14 @@ void LoopAnalyzer::LoopNode::incrementLoopNestDepth() {
BB
->
incrementLoopNestDepth
();
BB
->
incrementLoopNestDepth
();
}
}
bool
LoopAnalyzer
::
LoopNode
::
hasSelfEdge
()
const
{
for
(
CfgNode
*
Succ
:
BB
->
getOutEdges
())
{
if
(
Succ
==
BB
)
return
true
;
}
return
false
;
}
LoopAnalyzer
::
LoopAnalyzer
(
Cfg
*
Fn
)
:
Func
(
Fn
)
{
LoopAnalyzer
::
LoopAnalyzer
(
Cfg
*
Fn
)
:
Func
(
Fn
)
{
const
NodeList
&
Nodes
=
Func
->
getNodes
();
const
NodeList
&
Nodes
=
Func
->
getNodes
();
...
@@ -115,6 +123,8 @@ LoopAnalyzer::processNode(LoopAnalyzer::LoopNode &Node) {
...
@@ -115,6 +123,8 @@ LoopAnalyzer::processNode(LoopAnalyzer::LoopNode &Node) {
// Single node means no loop in the CFG
// Single node means no loop in the CFG
if
(
LoopStack
.
back
()
==
&
Node
)
{
if
(
LoopStack
.
back
()
==
&
Node
)
{
LoopStack
.
back
()
->
setOnStack
(
false
);
LoopStack
.
back
()
->
setOnStack
(
false
);
if
(
Node
.
hasSelfEdge
())
LoopStack
.
back
()
->
incrementLoopNestDepth
();
LoopStack
.
back
()
->
setDeleted
();
LoopStack
.
back
()
->
setDeleted
();
++
NumDeletedNodes
;
++
NumDeletedNodes
;
LoopStack
.
pop_back
();
LoopStack
.
pop_back
();
...
...
src/IceLoopAnalyzer.h
View file @
f49b2396
...
@@ -78,6 +78,7 @@ private:
...
@@ -78,6 +78,7 @@ private:
bool
isDeleted
()
const
{
return
Deleted
;
}
bool
isDeleted
()
const
{
return
Deleted
;
}
void
incrementLoopNestDepth
();
void
incrementLoopNestDepth
();
bool
hasSelfEdge
()
const
;
private
:
private
:
CfgNode
*
BB
;
CfgNode
*
BB
;
...
...
tests_lit/llvm2ice_tests/loop-nest-depth.ll
View file @
f49b2396
...
@@ -279,3 +279,28 @@ out:
...
@@ -279,3 +279,28 @@ out:
; CHECK-NEXT: out:
; CHECK-NEXT: out:
; CHECK-NEXT: LoopNestDepth = 0
; CHECK-NEXT: LoopNestDepth = 0
; CHECK-LABEL: Before RMW
; CHECK-LABEL: Before RMW
define
internal
void
@test_single_block_loop
(
i32
%count
)
{
entry:
br
label
%body
body:
; %i = phi i32 [ 0, %entry ], [ %inc, %body ]
; A normal loop would have a phi instruction like above for the induction
; variable, but that may introduce new basic blocks due to phi edge splitting,
; so we use an alternative definition for %i to make the test more clear.
%i
=
add
i32
%count
,
1
%inc
=
add
i32
%i
,
1
%cmp
=
icmp
slt
i32
%inc
,
%count
br
i1
%cmp
,
label
%body
,
label
%exit
exit:
ret
void
}
; CHECK-LABEL: After loop nest depth analysis
; CHECK-NEXT: entry:
; CHECK-NEXT: LoopNestDepth = 0
; CHECK-NEXT: body:
; CHECK-NEXT: LoopNestDepth = 1
; CHECK-NEXT: exit:
; CHECK-NEXT: LoopNestDepth = 0
; CHECK-LABEL: Before RMW
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment