Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
86a1467f
Commit
86a1467f
authored
18 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
Fold (trunc (srl x, c)) -> (srl (trunc x), c)
llvm-svn: 28138
parent
907e392d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/lib/Target/TargetLowering.cpp
+32
-0
32 additions, 0 deletions
llvm/lib/Target/TargetLowering.cpp
with
32 additions
and
0 deletions
llvm/lib/Target/TargetLowering.cpp
+
32
−
0
View file @
86a1467f
...
...
@@ -608,9 +608,41 @@ bool TargetLowering::SimplifyDemandedBits(SDOperand Op, uint64_t DemandedMask,
break
;
}
case
ISD
::
TRUNCATE
:
{
// Simplify the input, using demanded bit information, and compute the known
// zero/one bits live out.
if
(
SimplifyDemandedBits
(
Op
.
getOperand
(
0
),
DemandedMask
,
KnownZero
,
KnownOne
,
TLO
,
Depth
+
1
))
return
true
;
// If the input is only used by this truncate, see if we can shrink it based
// on the known demanded bits.
if
(
Op
.
getOperand
(
0
).
Val
->
hasOneUse
())
{
SDOperand
In
=
Op
.
getOperand
(
0
);
switch
(
In
.
getOpcode
())
{
default:
break
;
case
ISD
::
SRL
:
// Shrink SRL by a constant if none of the high bits shifted in are
// demanded.
if
(
ConstantSDNode
*
ShAmt
=
dyn_cast
<
ConstantSDNode
>
(
In
.
getOperand
(
1
))){
uint64_t
HighBits
=
MVT
::
getIntVTBitMask
(
In
.
getValueType
());
HighBits
&=
~
MVT
::
getIntVTBitMask
(
Op
.
getValueType
());
HighBits
>>=
ShAmt
->
getValue
();
if
(
ShAmt
->
getValue
()
<
MVT
::
getSizeInBits
(
Op
.
getValueType
())
&&
(
DemandedMask
&
HighBits
)
==
0
)
{
// None of the shifted in bits are needed. Add a truncate of the
// shift input, then shift it.
SDOperand
NewTrunc
=
TLO
.
DAG
.
getNode
(
ISD
::
TRUNCATE
,
Op
.
getValueType
(),
In
.
getOperand
(
0
));
return
TLO
.
CombineTo
(
Op
,
TLO
.
DAG
.
getNode
(
ISD
::
SRL
,
Op
.
getValueType
(),
NewTrunc
,
In
.
getOperand
(
1
)));
}
}
break
;
}
}
assert
((
KnownZero
&
KnownOne
)
==
0
&&
"Bits known to be one AND zero?"
);
uint64_t
OutMask
=
MVT
::
getIntVTBitMask
(
Op
.
getValueType
());
KnownZero
&=
OutMask
;
...
...
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