Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LLVM bpEVL
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Albano
LLVM bpEVL
Commits
bd518d15
Commit
bd518d15
authored
19 years ago
by
Robert Bocchino
Browse files
Options
Downloads
Patches
Plain Diff
Added lower packed support for the extractelement operation.
llvm-svn: 25180
parent
2c966e76
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/lib/Transforms/Scalar/LowerPacked.cpp
+31
-0
31 additions, 0 deletions
llvm/lib/Transforms/Scalar/LowerPacked.cpp
llvm/lib/Transforms/Scalar/SCCP.cpp
+12
-0
12 additions, 0 deletions
llvm/lib/Transforms/Scalar/SCCP.cpp
with
43 additions
and
0 deletions
llvm/lib/Transforms/Scalar/LowerPacked.cpp
+
31
−
0
View file @
bd518d15
...
...
@@ -59,6 +59,10 @@ public:
/// @param SELI the select operator to convert
void
visitSelectInst
(
SelectInst
&
SELI
);
/// @brief Lowers packed extractelement instructions.
/// @param EI the extractelement operator to convert
void
visitExtractElementInst
(
ExtractElementInst
&
EI
);
/// This function asserts if the instruction is a PackedType but
/// is handled by another function.
///
...
...
@@ -332,6 +336,33 @@ void LowerPacked::visitSelectInst(SelectInst& SELI)
}
}
void
LowerPacked
::
visitExtractElementInst
(
ExtractElementInst
&
EI
)
{
std
::
vector
<
Value
*>&
op0Vals
=
getValues
(
EI
.
getOperand
(
0
));
const
PackedType
*
PTy
=
cast
<
PackedType
>
(
EI
.
getOperand
(
0
)
->
getType
());
Value
*
op1
=
EI
.
getOperand
(
1
);
if
(
ConstantUInt
*
C
=
dyn_cast
<
ConstantUInt
>
(
op1
))
{
EI
.
replaceAllUsesWith
(
op0Vals
[
C
->
getValue
()]);
}
else
{
AllocaInst
*
alloca
=
new
AllocaInst
(
PTy
->
getElementType
(),
ConstantUInt
::
get
(
Type
::
UIntTy
,
PTy
->
getNumElements
()),
EI
.
getName
()
+
".alloca"
,
&
(
EI
.
getParent
()
->
getParent
()
->
getEntryBlock
().
front
()));
for
(
unsigned
i
=
0
;
i
<
PTy
->
getNumElements
();
++
i
)
{
GetElementPtrInst
*
GEP
=
new
GetElementPtrInst
(
alloca
,
ConstantUInt
::
get
(
Type
::
UIntTy
,
i
),
"store.ge"
,
&
EI
);
new
StoreInst
(
op0Vals
[
i
],
GEP
,
&
EI
);
}
GetElementPtrInst
*
GEP
=
new
GetElementPtrInst
(
alloca
,
op1
,
EI
.
getName
()
+
".ge"
,
&
EI
);
LoadInst
*
load
=
new
LoadInst
(
GEP
,
EI
.
getName
()
+
".load"
,
&
EI
);
EI
.
replaceAllUsesWith
(
load
);
}
Changed
=
true
;
instrsToRemove
.
push_back
(
&
EI
);
}
bool
LowerPacked
::
runOnFunction
(
Function
&
F
)
{
// initialize
...
...
This diff is collapsed.
Click to expand it.
llvm/lib/Transforms/Scalar/SCCP.cpp
+
12
−
0
View file @
bd518d15
...
...
@@ -322,6 +322,7 @@ private:
void
visitSelectInst
(
SelectInst
&
I
);
void
visitBinaryOperator
(
Instruction
&
I
);
void
visitShiftInst
(
ShiftInst
&
I
)
{
visitBinaryOperator
(
I
);
}
void
visitExtractElementInst
(
ExtractElementInst
&
I
);
// Instructions that cannot be folded away...
void
visitStoreInst
(
Instruction
&
I
);
...
...
@@ -728,6 +729,17 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
}
}
void
SCCPSolver
::
visitExtractElementInst
(
ExtractElementInst
&
I
)
{
LatticeVal
&
ValState
=
getValueState
(
I
.
getOperand
(
0
));
LatticeVal
&
IdxState
=
getValueState
(
I
.
getOperand
(
1
));
if
(
ValState
.
isOverdefined
()
||
IdxState
.
isOverdefined
())
markOverdefined
(
&
I
);
else
if
(
ValState
.
isConstant
()
&&
IdxState
.
isConstant
())
markConstant
(
&
I
,
ConstantExpr
::
getExtractElement
(
ValState
.
getConstant
(),
IdxState
.
getConstant
()));
}
// Handle getelementptr instructions... if all operands are constants then we
// can turn this into a getelementptr ConstantExpr.
//
...
...
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