summaryrefslogtreecommitdiff
path: root/compiler/cmm
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-08-18 18:38:28 +0200
committerBen Gamari <ben@smart-cactus.org>2015-08-18 18:42:12 +0200
commit3849dac59209cc2608636ae120eac54237d882c5 (patch)
treedf6a9cb2fc80dcfde31785188641b4b193016d16 /compiler/cmm
parente43350573b7a6f233bc7ef2a8badaeb15fb46f34 (diff)
downloadhaskell-wip/d1141.tar.gz
Refactor: delete most of the module FastTypeswip/d1141
This reverses some of the work done in #1405, and goes back to the assumption that the bootstrap compiler understands GHC-haskell. In particular: * use MagicHash instead of _ILIT and _CLIT * pattern matching on I# if possible, instead of using iUnbox unnecessarily * use Int#/Char#/Addr# instead of the following type synonyms: - type FastInt = Int# - type FastChar = Char# - type FastPtr a = Addr# * inline the following functions: - iBox = I# - cBox = C# - fastChr = chr# - fastOrd = ord# - eqFastChar = eqChar# - shiftLFastInt = uncheckedIShiftL# - shiftR_FastInt = uncheckedIShiftRL# - shiftRLFastInt = uncheckedIShiftRL# * delete the following unused functions: - minFastInt - maxFastInt - uncheckedIShiftRA# - castFastPtr - panicDocFastInt and pprPanicFastInt * rename panicFastInt back to panic# These functions remain, since they actually do something: * iUnbox * bitAndFastInt * bitOrFastInt Test Plan: validate Reviewers: austin, bgamari Subscribers: rwbarton Differential Revision: https://phabricator.haskell.org/D1141 GHC Trac Issues: #1405
Diffstat (limited to 'compiler/cmm')
-rw-r--r--compiler/cmm/CmmOpt.hs24
1 files changed, 6 insertions, 18 deletions
diff --git a/compiler/cmm/CmmOpt.hs b/compiler/cmm/CmmOpt.hs
index 84499b97de..7c634c2201 100644
--- a/compiler/cmm/CmmOpt.hs
+++ b/compiler/cmm/CmmOpt.hs
@@ -21,7 +21,6 @@ import CmmUtils
import Cmm
import DynFlags
-import FastTypes
import Outputable
import Platform
@@ -376,30 +375,19 @@ cmmMachOpFoldM _ _ _ = Nothing
-- This algorithm for determining the $\log_2$ of exact powers of 2 comes
-- from GCC. It requires bit manipulation primitives, and we use GHC
-- extensions. Tough.
---
--- Used to be in MachInstrs --SDM.
--- ToDo: remove use of unboxery --SDM.
-
--- Unboxery removed in favor of FastInt; but is the function supposed to fail
--- on inputs >= 2147483648, or was that just an implementation artifact?
--- And is this speed-critical, or can we just use Integer operations
--- (including Data.Bits)?
--- --Isaac Dupree
exactLog2 :: Integer -> Maybe Integer
-exactLog2 x_
- = if (x_ <= 0 || x_ >= 2147483648) then
+exactLog2 x
+ = if (x <= 0 || x >= 2147483648) then
Nothing
else
- case iUnbox (fromInteger x_) of { x ->
- if (x `bitAndFastInt` negateFastInt x) /=# x then
+ if (x .&. (-x)) /= x then
Nothing
else
- Just (toInteger (iBox (pow2 x)))
- }
+ Just (pow2 x)
where
- pow2 x | x ==# _ILIT(1) = _ILIT(0)
- | otherwise = _ILIT(1) +# pow2 (x `shiftR_FastInt` _ILIT(1))
+ pow2 x | x == 1 = 0
+ | otherwise = 1 + pow2 (x `shiftR` 1)
-- -----------------------------------------------------------------------------
-- Utils