Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
sheaf
GHC
Commits
4af6126d
Commit
4af6126d
authored
4 years ago
by
Sylvain Henry
Committed by
Marge Bot
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use static array in zeroCount
parent
480a38d4
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
libraries/base/GHC/Float/ConversionUtils.hs
+6
-37
6 additions, 37 deletions
libraries/base/GHC/Float/ConversionUtils.hs
with
6 additions
and
37 deletions
libraries/base/GHC/Float/ConversionUtils.hs
+
6
−
37
View file @
4af6126d
...
...
@@ -33,13 +33,10 @@ default ()
#
define
TO64
integerToInt64
#
toByte64
#
::
Int64
#
->
Int
#
toByte64
#
i
=
word2Int
#
(
and
#
255
##
(
int2Word
#
(
int64ToInt
#
i
)))
-- Double mantissae have 53 bits, too much for Int#
elim64
#
::
Int64
#
->
Int
#
->
(
#
Integer
,
Int
#
#
)
elim64
#
n
e
=
case
zeroCount
(
toByte64
#
n
)
of
case
zeroCount
(
int64ToInt
#
n
)
of
t
|
isTrue
#
(
e
<=#
t
)
->
(
#
integerFromInt64
#
(
uncheckedIShiftRA64
#
n
e
),
0
#
#
)
|
isTrue
#
(
t
<#
8
#
)
->
(
#
integerFromInt64
#
(
uncheckedIShiftRA64
#
n
t
),
e
-#
t
#
)
|
otherwise
->
elim64
#
(
uncheckedIShiftRA64
#
n
8
#
)
(
e
-#
8
#
)
...
...
@@ -60,41 +57,13 @@ elimZerosInteger m e = elim64# (TO64 m) e
elimZerosInt
#
::
Int
#
->
Int
#
->
(
#
Integer
,
Int
#
#
)
elimZerosInt
#
n
e
=
case
zeroCount
(
toByte
#
n
)
of
case
zeroCount
n
of
t
|
isTrue
#
(
e
<=#
t
)
->
(
#
IS
(
uncheckedIShiftRA
#
n
e
),
0
#
#
)
|
isTrue
#
(
t
<#
8
#
)
->
(
#
IS
(
uncheckedIShiftRA
#
n
t
),
e
-#
t
#
)
|
otherwise
->
elimZerosInt
#
(
uncheckedIShiftRA
#
n
8
#
)
(
e
-#
8
#
)
{-# INLINE zeroCount #-}
-- | Number of trailing zero bits in a byte
zeroCount
::
Int
#
->
Int
#
zeroCount
i
=
case
zeroCountArr
of
BA
ba
->
indexInt8Array
#
ba
i
toByte
#
::
Int
#
->
Int
#
toByte
#
i
=
word2Int
#
(
and
#
255
##
(
int2Word
#
i
))
data
BA
=
BA
ByteArray
#
-- Number of trailing zero bits in a byte
zeroCountArr
::
BA
zeroCountArr
=
let
mkArr
s
=
case
newByteArray
#
256
#
s
of
(
#
s1
,
mba
#
)
->
case
writeInt8Array
#
mba
0
#
8
#
s1
of
s2
->
let
fillA
step
val
idx
st
|
isTrue
#
(
idx
<#
256
#
)
=
case
writeInt8Array
#
mba
idx
val
st
of
nx
->
fillA
step
val
(
idx
+#
step
)
nx
|
isTrue
#
(
step
<#
256
#
)
=
fillA
(
2
#
*#
step
)
(
val
+#
1
#
)
step
st
|
otherwise
=
st
in
case
fillA
2
#
0
#
1
#
s2
of
s3
->
case
unsafeFreezeByteArray
#
mba
s3
of
(
#
_
,
ba
#
)
->
ba
in
case
mkArr
realWorld
#
of
b
->
BA
b
zeroCount
i
=
indexInt8OffAddr
#
arr
(
word2Int
#
(
narrow8Word
#
(
int2Word
#
i
)))
-- index must be in [0,255]
where
arr
=
"
\8\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\6\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\7\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\6\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0
"
#
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