Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
a7e0d448
Commit
a7e0d448
authored
Oct 23, 2012
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a small -fPIC optimisation
(PicBaseReg + lit) + N ==> PicBaseReg + (lit+N)
parent
2324b40f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
compiler/cmm/CmmOpt.hs
compiler/cmm/CmmOpt.hs
+14
-0
No files found.
compiler/cmm/CmmOpt.hs
View file @
a7e0d448
...
@@ -183,6 +183,20 @@ cmmMachOpFoldM dflags mop1@(MO_Add{}) [CmmMachOp mop2@(MO_Sub{}) [arg1,arg2], ar
...
@@ -183,6 +183,20 @@ cmmMachOpFoldM dflags mop1@(MO_Add{}) [CmmMachOp mop2@(MO_Sub{}) [arg1,arg2], ar
|
not
(
isLit
arg1
)
&&
not
(
isPicReg
arg1
)
|
not
(
isLit
arg1
)
&&
not
(
isPicReg
arg1
)
=
Just
(
cmmMachOpFold
dflags
mop1
[
arg1
,
cmmMachOpFold
dflags
mop2
[
arg3
,
arg2
]])
=
Just
(
cmmMachOpFold
dflags
mop1
[
arg1
,
cmmMachOpFold
dflags
mop2
[
arg3
,
arg2
]])
-- special case: (PicBaseReg + lit) + N ==> PicBaseReg + (lit+N)
--
-- this is better because lit+N is a single link-time constant (e.g. a
-- CmmLabelOff), so the right-hand expression needs only one
-- instruction, whereas the left needs two. This happens when pointer
-- tagging gives us label+offset, and PIC turns the label into
-- PicBaseReg + label.
--
cmmMachOpFoldM
_
MO_Add
{}
[
CmmMachOp
op
@
MO_Add
{}
[
pic
,
CmmLit
lit
]
,
CmmLit
(
CmmInt
n
rep
)
]
|
isPicReg
pic
=
Just
$
CmmMachOp
op
[
pic
,
CmmLit
$
cmmOffsetLit
lit
off
]
where
off
=
fromIntegral
(
narrowS
rep
n
)
-- Make a RegOff if we can
-- Make a RegOff if we can
cmmMachOpFoldM
_
(
MO_Add
_
)
[
CmmReg
reg
,
CmmLit
(
CmmInt
n
rep
)]
cmmMachOpFoldM
_
(
MO_Add
_
)
[
CmmReg
reg
,
CmmLit
(
CmmInt
n
rep
)]
=
Just
$
cmmRegOff
reg
(
fromIntegral
(
narrowS
rep
n
))
=
Just
$
cmmRegOff
reg
(
fromIntegral
(
narrowS
rep
n
))
...
...
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