Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TAS-OPT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Kaufmann
TAS-OPT
Commits
9f0c3c74
Commit
9f0c3c74
authored
5 years ago
by
guruhegde
Browse files
Options
Downloads
Patches
Plain Diff
Fix index variable.
* Some positive throughput in tas
parent
743cf699
Branches
master
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ForLoopV2.cpp
+6
-6
6 additions, 6 deletions
src/ForLoopV2.cpp
src/ForLoopV2.h
+1
-1
1 addition, 1 deletion
src/ForLoopV2.h
src/LoopSplitter.cpp
+3
-3
3 additions, 3 deletions
src/LoopSplitter.cpp
with
10 additions
and
10 deletions
src/ForLoopV2.cpp
+
6
−
6
View file @
9f0c3c74
...
...
@@ -24,7 +24,7 @@ void IRLoop::analyze(Loop * L) {
}
}
void
IRLoop
::
constructEmptyLoop
(
AllocaInst
*
TripCount
,
Function
*
F
)
{
void
IRLoop
::
constructEmptyLoop
(
AllocaInst
*
TripCount
,
AllocaInst
*
Idx
,
Function
*
F
)
{
Latch
=
BasicBlock
::
Create
(
Ctx
,
"latch"
,
F
);
Header
=
BasicBlock
::
Create
(
Ctx
,
"header"
,
F
,
Latch
);
PreHeader
=
BasicBlock
::
Create
(
Ctx
,
"preheader"
,
F
,
Header
);
...
...
@@ -32,18 +32,18 @@ void IRLoop::constructEmptyLoop(AllocaInst * TripCount, Function * F) {
// Create Loop Index Variable.
IRBuilder
<>
Builder
(
Ctx
);
Builder
.
SetInsertPoint
(
&
F
->
getEntryBlock
().
front
());
IdxAlloca
=
Builder
.
CreateAlloca
(
Builder
.
getInt32Ty
());
//
Builder.SetInsertPoint(&F->getEntryBlock().front());
//
IdxAlloca = Builder.CreateAlloca(Builder.getInt32Ty());
// Set Index variable to 0 in preheader block.
Builder
.
SetInsertPoint
(
PreHeader
);
Builder
.
CreateStore
(
Builder
.
getInt32
(
0
),
Idx
Alloca
);
Builder
.
CreateStore
(
Builder
.
getInt32
(
0
),
Idx
);
Builder
.
CreateBr
(
Header
);
// Populate latch block
Builder
.
SetInsertPoint
(
Latch
);
auto
BackEdge
=
Builder
.
CreateBr
(
Header
);
addIncrementIndexOp
(
Idx
Alloca
,
BackEdge
);
addIncrementIndexOp
(
Idx
,
BackEdge
);
// Branch Empty block to latch
Builder
.
SetInsertPoint
(
EmptyBody
);
...
...
@@ -51,7 +51,7 @@ void IRLoop::constructEmptyLoop(AllocaInst * TripCount, Function * F) {
// Populate header block
Builder
.
SetInsertPoint
(
Header
);
auto
IdxVal
=
Builder
.
CreateLoad
(
Idx
Alloca
);
auto
IdxVal
=
Builder
.
CreateLoad
(
Idx
);
auto
TC
=
Builder
.
CreateLoad
(
TripCount
);
auto
*
Icmp
=
Builder
.
CreateICmpSLT
(
IdxVal
,
TC
,
"loop-predicate"
);
Builder
.
CreateCondBr
(
Icmp
,
EmptyBody
,
EmptyBody
);
...
...
This diff is collapsed.
Click to expand it.
src/ForLoopV2.h
+
1
−
1
View file @
9f0c3c74
...
...
@@ -27,7 +27,7 @@ public:
IRLoop
(
llvm
::
LLVMContext
&
C
)
:
Ctx
(
C
)
{}
void
analyze
(
llvm
::
Loop
*
L
);
void
constructEmptyLoop
(
llvm
::
AllocaInst
*
TripCount
,
void
constructEmptyLoop
(
llvm
::
AllocaInst
*
TripCount
,
llvm
::
AllocaInst
*
Idx
,
llvm
::
Function
*
F
);
void
extractLoopSkeleton
(
llvm
::
Loop
*
L
);
void
setLoopBlocks
(
std
::
vector
<
llvm
::
BasicBlock
*>
&
Blocks
);
...
...
This diff is collapsed.
Click to expand it.
src/LoopSplitter.cpp
+
3
−
3
View file @
9f0c3c74
...
...
@@ -86,18 +86,19 @@ bool LoopSplitter::run() {
EndBlocks
.
push_back
(
BodyEnd
);
auto
EntryBlock
=
getPreLoopBlock
(
L0
);
EntryBlock
->
printAsOperand
(
errs
());
errs
()
<<
" - Entry
\n
"
;
ExitBlock
=
L0
->
getExitBlock
();
auto
TripCount
=
getLoopTripCount
(
L0
);
assert
(
ExitBlock
&&
"Loop must have a single exit block!"
);
auto
ParentLoop
=
IRLoop
(
F
->
getContext
());
ParentLoop
.
extractLoopSkeleton
(
L0
);
auto
Index
=
getLoopIndexVar
(
L0
);
errs
()
<<
*
Index
;
std
::
vector
<
IRLoop
>
Loops
;
for
(
int
i
=
0
;
i
<
AnnotatedVars
.
size
();
++
i
)
{
Loops
.
push_back
(
IRLoop
(
F
->
getContext
()));
Loops
.
back
().
constructEmptyLoop
(
TripCount
,
F
);
Loops
.
back
().
constructEmptyLoop
(
TripCount
,
Index
,
F
);
}
Loops
.
push_back
(
ParentLoop
);
...
...
@@ -128,7 +129,6 @@ bool LoopSplitter::run() {
Loops
[
i
].
setLoopBlocks
(
LoopBlocks
[
i
]);
}
F
->
print
(
errs
());
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment