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
8d0bacbb
Commit
8d0bacbb
authored
21 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
Implement Transforms/InstCombine/cast.ll:test13, a case which occurs in a
hot 164.gzip loop. llvm-svn: 11702
parent
9c08d09d
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/InstructionCombining.cpp
+33
-3
33 additions, 3 deletions
llvm/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/lib/Transforms/Scalar/TailDuplication.cpp
+2
-1
2 additions, 1 deletion
llvm/lib/Transforms/Scalar/TailDuplication.cpp
with
35 additions
and
4 deletions
llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+
33
−
3
View file @
8d0bacbb
...
@@ -2004,9 +2004,14 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
...
@@ -2004,9 +2004,14 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
Instruction
*
InstCombiner
::
visitGetElementPtrInst
(
GetElementPtrInst
&
GEP
)
{
Instruction
*
InstCombiner
::
visitGetElementPtrInst
(
GetElementPtrInst
&
GEP
)
{
// Is it 'getelementptr %P, long 0' or 'getelementptr %P'
// Is it 'getelementptr %P, long 0' or 'getelementptr %P'
// If so, eliminate the noop.
// If so, eliminate the noop.
if
((
GEP
.
getNumOperands
()
==
2
&&
if
(
GEP
.
getNumOperands
()
==
1
)
GEP
.
getOperand
(
1
)
==
Constant
::
getNullValue
(
Type
::
LongTy
))
||
return
ReplaceInstUsesWith
(
GEP
,
GEP
.
getOperand
(
0
));
GEP
.
getNumOperands
()
==
1
)
bool
HasZeroPointerIndex
=
false
;
if
(
Constant
*
C
=
dyn_cast
<
Constant
>
(
GEP
.
getOperand
(
1
)))
HasZeroPointerIndex
=
C
->
isNullValue
();
if
(
GEP
.
getNumOperands
()
==
2
&&
HasZeroPointerIndex
)
return
ReplaceInstUsesWith
(
GEP
,
GEP
.
getOperand
(
0
));
return
ReplaceInstUsesWith
(
GEP
,
GEP
.
getOperand
(
0
));
// Combine Indices - If the source pointer to this getelementptr instruction
// Combine Indices - If the source pointer to this getelementptr instruction
...
@@ -2073,6 +2078,31 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
...
@@ -2073,6 +2078,31 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// Replace all uses of the GEP with the new constexpr...
// Replace all uses of the GEP with the new constexpr...
return
ReplaceInstUsesWith
(
GEP
,
CE
);
return
ReplaceInstUsesWith
(
GEP
,
CE
);
}
}
}
else
if
(
ConstantExpr
*
CE
=
dyn_cast
<
ConstantExpr
>
(
GEP
.
getOperand
(
0
)))
{
if
(
CE
->
getOpcode
()
==
Instruction
::
Cast
)
{
if
(
HasZeroPointerIndex
)
{
// transform: GEP (cast [10 x ubyte]* X to [0 x ubyte]*), long 0, ...
// into : GEP [10 x ubyte]* X, long 0, ...
//
// This occurs when the program declares an array extern like "int X[];"
//
Constant
*
X
=
CE
->
getOperand
(
0
);
const
PointerType
*
CPTy
=
cast
<
PointerType
>
(
CE
->
getType
());
if
(
const
PointerType
*
XTy
=
dyn_cast
<
PointerType
>
(
X
->
getType
()))
if
(
const
ArrayType
*
XATy
=
dyn_cast
<
ArrayType
>
(
XTy
->
getElementType
()))
if
(
const
ArrayType
*
CATy
=
dyn_cast
<
ArrayType
>
(
CPTy
->
getElementType
()))
if
(
CATy
->
getElementType
()
==
XATy
->
getElementType
())
{
// At this point, we know that the cast source type is a pointer
// to an array of the same type as the destination pointer
// array. Because the array type is never stepped over (there
// is a leading zero) we can fold the cast into this GEP.
GEP
.
setOperand
(
0
,
X
);
return
&
GEP
;
}
}
}
}
}
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
llvm/lib/Transforms/Scalar/TailDuplication.cpp
+
2
−
1
View file @
8d0bacbb
...
@@ -126,7 +126,8 @@ bool TailDup::canEliminateUnconditionalBranch(TerminatorInst *TI) {
...
@@ -126,7 +126,8 @@ bool TailDup::canEliminateUnconditionalBranch(TerminatorInst *TI) {
// Basically, we refuse to make the transformation if any of the values
// Basically, we refuse to make the transformation if any of the values
// computed in the 'tail' are used in any other basic blocks.
// computed in the 'tail' are used in any other basic blocks.
BasicBlock
*
Tail
=
TI
->
getSuccessor
(
0
);
BasicBlock
*
Tail
=
TI
->
getSuccessor
(
0
);
assert
(
isa
<
BranchInst
>
(
TI
)
&&
cast
<
BranchInst
>
(
TI
)
->
isUnconditional
());
for
(
BasicBlock
::
iterator
I
=
Tail
->
begin
(),
E
=
Tail
->
end
();
I
!=
E
;
++
I
)
for
(
BasicBlock
::
iterator
I
=
Tail
->
begin
(),
E
=
Tail
->
end
();
I
!=
E
;
++
I
)
for
(
Value
::
use_iterator
UI
=
I
->
use_begin
(),
E
=
I
->
use_end
();
UI
!=
E
;
for
(
Value
::
use_iterator
UI
=
I
->
use_begin
(),
E
=
I
->
use_end
();
UI
!=
E
;
++
UI
)
{
++
UI
)
{
...
...
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