Simon Jakobi pushed to branch wip/sjakobi/21176-integer-bits at Glasgow Haskell Compiler / GHC
Commits:
a3b431f3 by David Eichmann at 2026-06-04T10:10:19+00:00
Hadrian: convert env variable ACLOCAL_PATH to unix paths.
Convert ACLOCAL_PATH to a unix style path when invoking autoreconf.
Autoreconf doesn't handle windows paths.
See Note [Autoreconf unix paths from ACLOCAL_PATH].
Fixes #27311
- - - - -
18f6138a by Simon Jakobi at 2026-06-04T20:20:31-04:00
testsuite: Deduplicate --only test names
config.only is assumed to be a set, but supplying --only overwrote it
with the (list) argparse result, which can contain duplicates. When a
test ran, config.only.remove(name) dropped only the first occurrence,
so a duplicated name lingered and was later misreported as a
"test not found" framework failure. Store it as a set instead.
Fixes #27322
Co-Authored-By: Claude Opus 4.7
- - - - -
2f3cc9ff by Simon Jakobi at 2026-06-08T07:55:49-04:00
testsuite: detect fast bignum via ghc-internal, not removed ghc-bignum
The ghc-bignum package was merged into ghc-internal, so the BIGNUM_GMP
probe in test.mk ran `ghc-pkg field ghc-bignum exposed-modules`, which
fails with "cannot find package ghc-bignum". That error went to stderr
and leaked into the captured stderr of every makefile_test, causing
spurious [bad stderr] failures across the suite. The probe also silently
returned empty, so config.have_fast_bignum was wrongly False even on GMP
builds.
Probe ghc-internal's extra-libraries for the gmp library instead: the
GMP backend module is an other-module (not exposed), but GMP_LIBS adds
gmp to extra-libraries only on a GMP build, so this distinguishes the
backends. Redirect stderr to keep any future missing-package error off
the harness's stderr.
This also removes a stale comment as per suggestion from hsyl20.
Co-Authored-By: Claude Opus 4.7
- - - - -
eb3bf6e7 by Alan Zimmerman at 2026-06-08T07:56:32-04:00
EPA: Rename Transform.anchorEof to addModuleCommentOrigDeltas
This now matches what it actually does.
- - - - -
46e87880 by Simon Jakobi at 2026-06-09T14:41:55+02:00
Add explicit setBit/clearBit/complementBit for instance Bits Integer (#21176)
The default setBit, clearBit, and complementBit methods allocate
intermediate Integers per call. Define them explicitly via the new
integerSetBit[#], integerClearBit[#] and integerComplementBit[#], built
on the BigNat# primitives, which avoid those allocations. Allocation is not
eliminated entirely -- the negative (IN) cases would need in-place mutation,
which is left as future work.
The default methods constant-folded on literal arguments via the
integerOr/integerAnd/integerXor rules, which fold literal Integers of any
size. The explicit functions have no such rule, so they (their Word-argument
wrappers, and the Bits Integer methods) are marked INLINE to expose the
underlying primops to the simplifier; see Note [INLINE for constant folding
of bit operations]. This restores folding only on the small-int (IS) path --
large literal Integers (IP/IN) are no longer constant-folded, a minor
regression for that case. T8832 covers the IS-path folding.
The new golden-output test T21176 checks all three operations against the
default implementations across the sign/size boundaries, recording each
result plus its integerCheck validity. The base and ghc-bignum interface-
stability export goldens gain the new functions.
The main changelog entry lives in changelog.d under a new ghc-internal
section (renamed from ghc-prim).
Co-Authored-By: Claude Opus 4.7
- - - - -
21 changed files:
- boot
- + changelog.d/T21176
- changelog.d/config
- hadrian/src/Hadrian/Oracles/Path.hs
- hadrian/src/Rules/BinaryDist.hs
- libraries/base/changelog.md
- libraries/ghc-internal/src/GHC/Internal/Bignum/Integer.hs
- libraries/ghc-internal/src/GHC/Internal/Bits.hs
- testsuite/driver/runtests.py
- testsuite/mk/test.mk
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-bignum-exports.stdout
- + testsuite/tests/numeric/should_run/T21176.hs
- + testsuite/tests/numeric/should_run/T21176.stdout
- testsuite/tests/numeric/should_run/all.T
- testsuite/tests/simplCore/should_compile/T8832.hs
- testsuite/tests/simplCore/should_compile/T8832.stdout
- utils/check-exact/Main.hs
- utils/check-exact/Transform.hs
Changes:
=====================================
boot
=====================================
@@ -52,9 +52,8 @@ def autoreconf():
# Run autoreconf on everything that needs it.
processes = {}
if os.name == 'nt':
- # Get the normalized ACLOCAL_PATH for Windows
- # This is necessary since on Windows this will be a Windows
- # path, which autoreconf doesn't know doesn't know how to handle.
+ # Convert ACLOCAL_PATH env variable to unix style paths on Windows
+ # See Note [Autoreconf unix paths from ACLOCAL_PATH]
ac_local = os.getenv('ACLOCAL_PATH', '')
ac_local_arg = re.sub(r';', r':', ac_local)
ac_local_arg = re.sub(r'\\', r'/', ac_local_arg)
=====================================
changelog.d/T21176
=====================================
@@ -0,0 +1,4 @@
+section: ghc-internal
+synopsis: Give ``setBit``, ``clearBit`` and ``complementBit`` explicit definitions in ``instance Bits Integer``, backed by new ``integerSetBit[#]``, ``integerClearBit[#]`` and ``integerComplementBit[#]`` functions. These avoid the intermediate ``Integer`` allocations of the previous default methods, although allocation is not eliminated entirely — notably the negative (``IN``) cases would require in-place mutation, which is left as future work. As a trade-off, constant folding of these operations now applies only to small (machine-word-sized) literal arguments; the previous default methods folded literal ``Integer`` arguments of any size via the ``integerOr``/``integerAnd``/``integerXor`` rules.
+issues: #21176
+mrs: !7772
=====================================
changelog.d/config
=====================================
@@ -27,7 +27,7 @@ sections: {
cmm Cmm
build-tools Build tools
base ``base`` library
- ghc-prim ``ghc-prim`` library
+ ghc-internal ``ghc-internal`` library
ghc-lib ``ghc`` library
ghc-heap ``ghc-heap`` library
ghc-experimental ``ghc-experimental`` library
=====================================
hadrian/src/Hadrian/Oracles/Path.hs
=====================================
@@ -1,6 +1,7 @@
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Oracles.Path (
- lookupInPath, fixAbsolutePathOnWindows, pathOracle
+ lookupInPath, fixAbsolutePathOnWindows, fixUnixPathsOnWindows,
+ pathOracle
) where
import Control.Monad
@@ -33,6 +34,14 @@ fixAbsolutePathOnWindows path =
else
return path
+-- | Fix a unix path list on Windows:
+-- * "C:\\foo\\bar;C:\\msys2\\bin" => "/c/foo/bar:/c/msys2/bin"
+fixUnixPathsOnWindows :: FilePath -> Action FilePath
+fixUnixPathsOnWindows paths =
+ if isWindows
+ then askOracle $ UnixPathList paths
+ else return paths
+
newtype LookupInPath = LookupInPath String
deriving (Binary, Eq, Hashable, NFData, Show)
type instance RuleResult LookupInPath = String
@@ -41,6 +50,10 @@ newtype WindowsPath = WindowsPath FilePath
deriving (Binary, Eq, Hashable, NFData, Show)
type instance RuleResult WindowsPath = String
+newtype UnixPathList = UnixPathList FilePath
+ deriving (Binary, Eq, Hashable, NFData, Show)
+type instance RuleResult UnixPathList = String
+
-- | Oracles for looking up paths. These are slow and require caching.
pathOracle :: Rules ()
pathOracle = do
@@ -50,6 +63,12 @@ pathOracle = do
putVerbose $ "| Windows path mapping: " ++ path ++ " => " ++ windowsPath
return windowsPath
+ void $ addOracleCache $ \(UnixPathList paths) -> do
+ Stdout out <- quietly $ cmd ["cygpath", "-p", "-u", paths]
+ let unixPaths = unifyPath $ dropWhileEnd isSpace out
+ putVerbose $ "| Unix path mapping: " ++ paths ++ " => " ++ unixPaths
+ return unixPaths
+
void $ addOracleCache $ \(LookupInPath name) -> do
path <- liftIO getSearchPath
exes <- liftIO (findExecutablesInDirectories path name)
=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -3,18 +3,19 @@ module Rules.BinaryDist where
import CommandLine
import Context
+import Data.Either
+import qualified Data.Set as Set
import Expression
+import Hadrian.Oracles.Path (fixUnixPathsOnWindows)
+import Oracles.Flavour
import Oracles.Setting
import Packages
+import Rules.Generate (generateSettings)
import Settings
+import qualified System.Directory.Extra as IO
import Settings.Program (programContext)
import Target
import Utilities
-import qualified System.Directory.Extra as IO
-import Data.Either
-import qualified Data.Set as Set
-import Oracles.Flavour
-import Rules.Generate (generateSettings)
{-
Note [Binary distributions]
@@ -343,7 +344,25 @@ bindistRules = do
ghcRoot <- topDirectory
copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4")
copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib")
- buildWithCmdOptions [] $
+
+ -- Note [Autoreconf unix paths from ACLOCAL_PATH]
+ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -- On Windows, autoreconf fails when the ACLOCAL_PATH env variable contains Windows-
+ -- style paths. This happens because MSYS2 automatically converts env variables to
+ -- Windows-style paths. To fix this, we convert ACLOCAL_PATH back to Unix style.
+ -- This is done both in the boot Python script and here when building a bindist.
+ win_host <- isWinHost
+ env <- if not win_host
+ then pure []
+ else do
+ aclocalPathMay <- getEnv "ACLOCAL_PATH"
+ case aclocalPathMay of
+ Nothing -> pure []
+ Just aclocalPath -> do
+ unixAclocalPath <- fixUnixPathsOnWindows aclocalPath
+ pure [AddEnv "ACLOCAL_PATH" unixAclocalPath]
+
+ buildWithCmdOptions env $
target (vanillaContext Stage1 ghc) (Autoreconf $ ghcRoot -/- "distrib") [] []
-- We clean after ourselves, moving the configure script we generated in
-- our bindist dir
=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,7 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
## 4.24.0.0 *TBA*
+ * Give `setBit`, `clearBit` and `complementBit` explicit definitions in `instance Bits Integer`, reducing intermediate allocations. ([GHC #21176](https://gitlab.haskell.org/ghc/ghc/-/issues/21176))
* Add `Bounded` instances for `Double`, `Float`, `CDouble` and `CFloat`. ([CLC proposal #402](https://github.com/haskell/core-libraries-committee/issues/402))
* Ensure that `Data.List.elem` and `notElem` can be specialized even when no list fusion happens. ([CLC proposal #412)(https://github.com/haskell/core-libraries-committee/issues/412))
=====================================
libraries/ghc-internal/src/GHC/Internal/Bignum/Integer.hs
=====================================
@@ -133,6 +133,12 @@ module GHC.Internal.Bignum.Integer
, integerBit
, integerTestBit#
, integerTestBit
+ , integerSetBit#
+ , integerSetBit
+ , integerClearBit#
+ , integerClearBit
+ , integerComplementBit#
+ , integerComplementBit
, integerShiftR#
, integerShiftR
, integerShiftL#
@@ -707,6 +713,113 @@ integerTestBit# (IN x) i
integerTestBit :: Integer -> Word -> Bool
integerTestBit !i (W# n) = isTrue# (integerTestBit# i n)
+{- Note [INLINE for constant folding of bit operations]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+While there are no dedicated constant-folding rules for
+integerSetBit#/integerClearBit#/integerComplementBit#, we do INLINE them (and
+their Word-argument wrappers and the corresponding Bits Integer methods) to make
+the underlying primops accessible for constant folding, e.g. so that
+`clearBit (bit 0) 0 :: Integer` folds to `IS 0#`. Test T8832 checks the folding
+for all three operations.
+-}
+
+-- | Set the /n/-th bit.
+--
+-- Fake 2's complement for negative values (might be slow)
+--
+-- @since 10.201.0
+integerSetBit# :: Integer -> Word# -> Integer
+{-# INLINE integerSetBit# #-} -- See Note [INLINE for constant folding of bit operations]
+integerSetBit# n@(IS x) i
+ | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##))
+ = IS (x `orI#` uncheckedIShiftL# 1# (word2Int# i))
+ | isTrue# (x >=# 0#)
+ = IP (bigNatSetBit# (bigNatFromWord# (int2Word# x)) i)
+ | True
+ = n
+integerSetBit# (IP x) i = IP (bigNatSetBit# x i)
+integerSetBit# (IN x) i = integerFromBigNatNeg#
+ (bigNatAddWord#
+ (bigNatClearBit# (bigNatSubWordUnsafe# x 1##) i)
+ 1##)
+
+-- | Set the /n/-th bit.
+--
+-- Fake 2's complement for negative values (might be slow)
+--
+-- @since 10.201.0
+integerSetBit :: Integer -> Word -> Integer
+{-# INLINE integerSetBit #-} -- See Note [INLINE for constant folding of bit operations]
+integerSetBit !i (W# n) = integerSetBit# i n
+
+-- | Clear the /n/-th bit.
+--
+-- Fake 2's complement for negative values (might be slow)
+--
+-- @since 10.201.0
+integerClearBit# :: Integer -> Word# -> Integer
+{-# INLINE integerClearBit# #-} -- See Note [INLINE for constant folding of bit operations]
+integerClearBit# n@(IS x) i
+ | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##))
+ = IS (x `andI#` notI# (uncheckedIShiftL# 1# (word2Int# i)))
+ | isTrue# (x >=# 0#)
+ = n
+ | True
+ = IN (bigNatAddWord#
+ (bigNatSetBit#
+ (bigNatFromWord#
+ (minusWord# (int2Word# (negateInt# x)) 1##))
+ i)
+ 1##)
+integerClearBit# (IP x) i = integerFromBigNat# (bigNatClearBit# x i)
+integerClearBit# (IN x) i = IN (bigNatAddWord#
+ (bigNatSetBit# (bigNatSubWordUnsafe# x 1##) i)
+ 1##)
+
+-- | Clear the /n/-th bit.
+--
+-- Fake 2's complement for negative values (might be slow)
+--
+-- @since 10.201.0
+integerClearBit :: Integer -> Word -> Integer
+{-# INLINE integerClearBit #-} -- See Note [INLINE for constant folding of bit operations]
+integerClearBit !i (W# n) = integerClearBit# i n
+
+-- | Reverse the /n/-th bit.
+--
+-- Fake 2's complement for negative values (might be slow)
+--
+-- @since 10.201.0
+integerComplementBit# :: Integer -> Word# -> Integer
+{-# INLINE integerComplementBit# #-} -- See Note [INLINE for constant folding of bit operations]
+integerComplementBit# (IS x) i
+ | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##))
+ = IS (x `xorI#` uncheckedIShiftL# 1# (word2Int# i))
+ | isTrue# (x >=# 0#)
+ = IP (bigNatSetBit# (bigNatFromWord# (int2Word# x)) i)
+ | True
+ = IN (bigNatAddWord#
+ (bigNatSetBit#
+ (bigNatFromWord# (minusWord# (int2Word# (negateInt# x)) 1##))
+ i)
+ 1##)
+integerComplementBit# (IP x) i = integerFromBigNat# (bigNatComplementBit# x i)
+integerComplementBit# (IN x) i = integerFromBigNatNeg#
+ (bigNatAddWord#
+ (bigNatComplementBit#
+ (bigNatSubWordUnsafe# x 1##)
+ i)
+ 1##)
+
+-- | Reverse the /n/-th bit.
+--
+-- Fake 2's complement for negative values (might be slow)
+--
+-- @since 10.201.0
+integerComplementBit :: Integer -> Word -> Integer
+{-# INLINE integerComplementBit #-} -- See Note [INLINE for constant folding of bit operations]
+integerComplementBit !i (W# n) = integerComplementBit# i n
+
-- | Shift-right operation
--
-- Fake 2's complement for negative values (might be slow)
=====================================
libraries/ghc-internal/src/GHC/Internal/Bits.hs
=====================================
@@ -564,6 +564,15 @@ instance Bits Integer where
| otherwise = integerShiftR x (fromIntegral (negate i))
testBit x i = integerTestBit x (fromIntegral i)
zeroBits = integerZero
+ -- INLINE on setBit/clearBit/complementBit preserves constant folding;
+ -- see Note [INLINE for constant folding of bit operations] in
+ -- GHC.Internal.Bignum.Integer.
+ setBit x i = integerSetBit x (fromIntegral i)
+ {-# INLINE setBit #-}
+ clearBit x i = integerClearBit x (fromIntegral i)
+ {-# INLINE clearBit #-}
+ complementBit x i = integerComplementBit x (fromIntegral i)
+ {-# INLINE complementBit #-}
bit (I# i) = integerBit# (int2Word# i)
popCount x = I# (integerPopCount# x)
=====================================
testsuite/driver/runtests.py
=====================================
@@ -133,7 +133,7 @@ if args.unexpected_output_dir:
config.unexpected_output_dir = Path(args.unexpected_output_dir)
if args.only:
- config.only = args.only
+ config.only = set(args.only)
config.run_only_some_tests = True
if args.skip:
=====================================
testsuite/mk/test.mk
=====================================
@@ -109,9 +109,11 @@ endif
HAVE_GDB := $(shell if gdb --version > /dev/null 2> /dev/null; then echo YES; else echo NO; fi)
HAVE_READELF := $(shell if readelf --version > /dev/null 2> /dev/null; then echo YES; else echo NO; fi)
-# we need a better way to find which backend is selected and if --check flag is
-# used
-BIGNUM_GMP := $(shell "$(GHC_PKG)" field ghc-bignum exposed-modules | grep GMP)
+# Detect whether the fast (GMP) bignum backend is in use. The GMP backend module
+# in ghc-internal is hidden, so we look instead for the gmp library it links
+# against: GMP_LIBS adds gmp to ghc-internal's extra-libraries only on a GMP
+# build.
+BIGNUM_GMP := $(shell "$(GHC_PKG)" field ghc-internal extra-libraries 2>/dev/null | grep gmp)
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e config.ghc_with_threaded_rts=True
=====================================
testsuite/tests/interface-stability/base-exports.stdout
=====================================
@@ -8371,8 +8371,12 @@ module GHC.Num where
integerBit# :: GHC.Internal.Prim.Word# -> Integer
integerCheck :: Integer -> GHC.Internal.Types.Bool
integerCheck# :: Integer -> GHC.Internal.Bignum.Primitives.Bool#
+ integerClearBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerClearBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerCompare :: Integer -> Integer -> GHC.Internal.Types.Ordering
integerComplement :: Integer -> Integer
+ integerComplementBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerComplementBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerDecodeDouble# :: GHC.Internal.Prim.Double# -> (# Integer, GHC.Internal.Prim.Int# #)
integerDiv :: Integer -> Integer -> Integer
integerDivMod :: Integer -> Integer -> (Integer, Integer)
@@ -8436,6 +8440,8 @@ module GHC.Num where
integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #)
integerRecipMod# :: Integer -> Natural -> (# Natural | () #)
integerRem :: Integer -> Integer -> Integer
+ integerSetBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerSetBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftL :: Integer -> GHC.Internal.Types.Word -> Integer
integerShiftL# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftR :: Integer -> GHC.Internal.Types.Word -> Integer
=====================================
testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
=====================================
@@ -8409,8 +8409,12 @@ module GHC.Num where
integerBit# :: GHC.Internal.Prim.Word# -> Integer
integerCheck :: Integer -> GHC.Internal.Types.Bool
integerCheck# :: Integer -> GHC.Internal.Bignum.Primitives.Bool#
+ integerClearBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerClearBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerCompare :: Integer -> Integer -> GHC.Internal.Types.Ordering
integerComplement :: Integer -> Integer
+ integerComplementBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerComplementBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerDecodeDouble# :: GHC.Internal.Prim.Double# -> (# Integer, GHC.Internal.Prim.Int# #)
integerDiv :: Integer -> Integer -> Integer
integerDivMod :: Integer -> Integer -> (Integer, Integer)
@@ -8474,6 +8478,8 @@ module GHC.Num where
integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #)
integerRecipMod# :: Integer -> Natural -> (# Natural | () #)
integerRem :: Integer -> Integer -> Integer
+ integerSetBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerSetBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftL :: Integer -> GHC.Internal.Types.Word -> Integer
integerShiftL# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftR :: Integer -> GHC.Internal.Types.Word -> Integer
=====================================
testsuite/tests/interface-stability/base-exports.stdout-mingw32
=====================================
@@ -8589,8 +8589,12 @@ module GHC.Num where
integerBit# :: GHC.Internal.Prim.Word# -> Integer
integerCheck :: Integer -> GHC.Internal.Types.Bool
integerCheck# :: Integer -> GHC.Internal.Bignum.Primitives.Bool#
+ integerClearBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerClearBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerCompare :: Integer -> Integer -> GHC.Internal.Types.Ordering
integerComplement :: Integer -> Integer
+ integerComplementBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerComplementBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerDecodeDouble# :: GHC.Internal.Prim.Double# -> (# Integer, GHC.Internal.Prim.Int# #)
integerDiv :: Integer -> Integer -> Integer
integerDivMod :: Integer -> Integer -> (Integer, Integer)
@@ -8654,6 +8658,8 @@ module GHC.Num where
integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #)
integerRecipMod# :: Integer -> Natural -> (# Natural | () #)
integerRem :: Integer -> Integer -> Integer
+ integerSetBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerSetBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftL :: Integer -> GHC.Internal.Types.Word -> Integer
integerShiftL# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftR :: Integer -> GHC.Internal.Types.Word -> Integer
=====================================
testsuite/tests/interface-stability/ghc-bignum-exports.stdout
=====================================
@@ -201,8 +201,12 @@ module GHC.Num.Integer where
integerBit# :: GHC.Internal.Prim.Word# -> Integer
integerCheck :: Integer -> GHC.Internal.Types.Bool
integerCheck# :: Integer -> GHC.Internal.Bignum.Primitives.Bool#
+ integerClearBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerClearBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerCompare :: Integer -> Integer -> GHC.Internal.Types.Ordering
integerComplement :: Integer -> Integer
+ integerComplementBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerComplementBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerDecodeDouble# :: GHC.Internal.Prim.Double# -> (# Integer, GHC.Internal.Prim.Int# #)
integerDiv :: Integer -> Integer -> Integer
integerDivMod :: Integer -> Integer -> (Integer, Integer)
@@ -266,6 +270,8 @@ module GHC.Num.Integer where
integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #)
integerRecipMod# :: Integer -> GHC.Internal.Bignum.Natural.Natural -> (# GHC.Internal.Bignum.Natural.Natural | () #)
integerRem :: Integer -> Integer -> Integer
+ integerSetBit :: Integer -> GHC.Internal.Types.Word -> Integer
+ integerSetBit# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftL :: Integer -> GHC.Internal.Types.Word -> Integer
integerShiftL# :: Integer -> GHC.Internal.Prim.Word# -> Integer
integerShiftR :: Integer -> GHC.Internal.Types.Word -> Integer
=====================================
testsuite/tests/numeric/should_run/T21176.hs
=====================================
@@ -0,0 +1,37 @@
+module Main where
+
+import Data.Bits
+import Data.Int (Int32, Int64)
+import Data.Foldable (for_)
+import GHC.Num.Integer (integerCheck)
+
+integers :: [Integer]
+integers = concatMap neighbours [minInt64, minInt32, 0, maxInt32, maxInt64]
+ where
+ neighbours i = [i - 2, i - 1, i, i + 1, i + 2]
+ minInt64 = toInteger (minBound :: Int64)
+ minInt32 = toInteger (minBound :: Int32)
+ maxInt32 = toInteger (maxBound :: Int32)
+ maxInt64 = toInteger (maxBound :: Int64)
+
+bits :: [Int]
+bits = [0, 1, 62, 63, 64]
+
+testXBit :: String -> (Integer -> Int -> Integer) -> (Integer -> Int -> Integer) -> IO ()
+testXBit name f model = do
+ putStrLn name
+ for_ integers $ \i ->
+ for_ bits $ \b -> do
+ let actual = f i b
+ expected = model i b
+ valid = if integerCheck actual then "valid" else "invalid"
+ matches = if actual == expected then "matches" else "differs"
+ putStrLn $ " " ++ show i ++ " " ++ show b ++ " -> " ++ show actual
+ ++ " [" ++ valid ++ ", " ++ matches ++ "]"
+ putStrLn ""
+
+main :: IO ()
+main = do
+ testXBit "setBit" setBit (\i b -> i .|. bit b)
+ testXBit "clearBit" clearBit (\i b -> i .&. complement (bit b))
+ testXBit "complementBit" complementBit (\i b -> i `xor` bit b)
=====================================
testsuite/tests/numeric/should_run/T21176.stdout
=====================================
@@ -0,0 +1,381 @@
+setBit
+ -9223372036854775810 0 -> -9223372036854775809 [valid, matches]
+ -9223372036854775810 1 -> -9223372036854775810 [valid, matches]
+ -9223372036854775810 62 -> -9223372036854775810 [valid, matches]
+ -9223372036854775810 63 -> -2 [valid, matches]
+ -9223372036854775810 64 -> -9223372036854775810 [valid, matches]
+ -9223372036854775809 0 -> -9223372036854775809 [valid, matches]
+ -9223372036854775809 1 -> -9223372036854775809 [valid, matches]
+ -9223372036854775809 62 -> -9223372036854775809 [valid, matches]
+ -9223372036854775809 63 -> -1 [valid, matches]
+ -9223372036854775809 64 -> -9223372036854775809 [valid, matches]
+ -9223372036854775808 0 -> -9223372036854775807 [valid, matches]
+ -9223372036854775808 1 -> -9223372036854775806 [valid, matches]
+ -9223372036854775808 62 -> -4611686018427387904 [valid, matches]
+ -9223372036854775808 63 -> -9223372036854775808 [valid, matches]
+ -9223372036854775808 64 -> -9223372036854775808 [valid, matches]
+ -9223372036854775807 0 -> -9223372036854775807 [valid, matches]
+ -9223372036854775807 1 -> -9223372036854775805 [valid, matches]
+ -9223372036854775807 62 -> -4611686018427387903 [valid, matches]
+ -9223372036854775807 63 -> -9223372036854775807 [valid, matches]
+ -9223372036854775807 64 -> -9223372036854775807 [valid, matches]
+ -9223372036854775806 0 -> -9223372036854775805 [valid, matches]
+ -9223372036854775806 1 -> -9223372036854775806 [valid, matches]
+ -9223372036854775806 62 -> -4611686018427387902 [valid, matches]
+ -9223372036854775806 63 -> -9223372036854775806 [valid, matches]
+ -9223372036854775806 64 -> -9223372036854775806 [valid, matches]
+ -2147483650 0 -> -2147483649 [valid, matches]
+ -2147483650 1 -> -2147483650 [valid, matches]
+ -2147483650 62 -> -2147483650 [valid, matches]
+ -2147483650 63 -> -2147483650 [valid, matches]
+ -2147483650 64 -> -2147483650 [valid, matches]
+ -2147483649 0 -> -2147483649 [valid, matches]
+ -2147483649 1 -> -2147483649 [valid, matches]
+ -2147483649 62 -> -2147483649 [valid, matches]
+ -2147483649 63 -> -2147483649 [valid, matches]
+ -2147483649 64 -> -2147483649 [valid, matches]
+ -2147483648 0 -> -2147483647 [valid, matches]
+ -2147483648 1 -> -2147483646 [valid, matches]
+ -2147483648 62 -> -2147483648 [valid, matches]
+ -2147483648 63 -> -2147483648 [valid, matches]
+ -2147483648 64 -> -2147483648 [valid, matches]
+ -2147483647 0 -> -2147483647 [valid, matches]
+ -2147483647 1 -> -2147483645 [valid, matches]
+ -2147483647 62 -> -2147483647 [valid, matches]
+ -2147483647 63 -> -2147483647 [valid, matches]
+ -2147483647 64 -> -2147483647 [valid, matches]
+ -2147483646 0 -> -2147483645 [valid, matches]
+ -2147483646 1 -> -2147483646 [valid, matches]
+ -2147483646 62 -> -2147483646 [valid, matches]
+ -2147483646 63 -> -2147483646 [valid, matches]
+ -2147483646 64 -> -2147483646 [valid, matches]
+ -2 0 -> -1 [valid, matches]
+ -2 1 -> -2 [valid, matches]
+ -2 62 -> -2 [valid, matches]
+ -2 63 -> -2 [valid, matches]
+ -2 64 -> -2 [valid, matches]
+ -1 0 -> -1 [valid, matches]
+ -1 1 -> -1 [valid, matches]
+ -1 62 -> -1 [valid, matches]
+ -1 63 -> -1 [valid, matches]
+ -1 64 -> -1 [valid, matches]
+ 0 0 -> 1 [valid, matches]
+ 0 1 -> 2 [valid, matches]
+ 0 62 -> 4611686018427387904 [valid, matches]
+ 0 63 -> 9223372036854775808 [valid, matches]
+ 0 64 -> 18446744073709551616 [valid, matches]
+ 1 0 -> 1 [valid, matches]
+ 1 1 -> 3 [valid, matches]
+ 1 62 -> 4611686018427387905 [valid, matches]
+ 1 63 -> 9223372036854775809 [valid, matches]
+ 1 64 -> 18446744073709551617 [valid, matches]
+ 2 0 -> 3 [valid, matches]
+ 2 1 -> 2 [valid, matches]
+ 2 62 -> 4611686018427387906 [valid, matches]
+ 2 63 -> 9223372036854775810 [valid, matches]
+ 2 64 -> 18446744073709551618 [valid, matches]
+ 2147483645 0 -> 2147483645 [valid, matches]
+ 2147483645 1 -> 2147483647 [valid, matches]
+ 2147483645 62 -> 4611686020574871549 [valid, matches]
+ 2147483645 63 -> 9223372039002259453 [valid, matches]
+ 2147483645 64 -> 18446744075857035261 [valid, matches]
+ 2147483646 0 -> 2147483647 [valid, matches]
+ 2147483646 1 -> 2147483646 [valid, matches]
+ 2147483646 62 -> 4611686020574871550 [valid, matches]
+ 2147483646 63 -> 9223372039002259454 [valid, matches]
+ 2147483646 64 -> 18446744075857035262 [valid, matches]
+ 2147483647 0 -> 2147483647 [valid, matches]
+ 2147483647 1 -> 2147483647 [valid, matches]
+ 2147483647 62 -> 4611686020574871551 [valid, matches]
+ 2147483647 63 -> 9223372039002259455 [valid, matches]
+ 2147483647 64 -> 18446744075857035263 [valid, matches]
+ 2147483648 0 -> 2147483649 [valid, matches]
+ 2147483648 1 -> 2147483650 [valid, matches]
+ 2147483648 62 -> 4611686020574871552 [valid, matches]
+ 2147483648 63 -> 9223372039002259456 [valid, matches]
+ 2147483648 64 -> 18446744075857035264 [valid, matches]
+ 2147483649 0 -> 2147483649 [valid, matches]
+ 2147483649 1 -> 2147483651 [valid, matches]
+ 2147483649 62 -> 4611686020574871553 [valid, matches]
+ 2147483649 63 -> 9223372039002259457 [valid, matches]
+ 2147483649 64 -> 18446744075857035265 [valid, matches]
+ 9223372036854775805 0 -> 9223372036854775805 [valid, matches]
+ 9223372036854775805 1 -> 9223372036854775807 [valid, matches]
+ 9223372036854775805 62 -> 9223372036854775805 [valid, matches]
+ 9223372036854775805 63 -> 18446744073709551613 [valid, matches]
+ 9223372036854775805 64 -> 27670116110564327421 [valid, matches]
+ 9223372036854775806 0 -> 9223372036854775807 [valid, matches]
+ 9223372036854775806 1 -> 9223372036854775806 [valid, matches]
+ 9223372036854775806 62 -> 9223372036854775806 [valid, matches]
+ 9223372036854775806 63 -> 18446744073709551614 [valid, matches]
+ 9223372036854775806 64 -> 27670116110564327422 [valid, matches]
+ 9223372036854775807 0 -> 9223372036854775807 [valid, matches]
+ 9223372036854775807 1 -> 9223372036854775807 [valid, matches]
+ 9223372036854775807 62 -> 9223372036854775807 [valid, matches]
+ 9223372036854775807 63 -> 18446744073709551615 [valid, matches]
+ 9223372036854775807 64 -> 27670116110564327423 [valid, matches]
+ 9223372036854775808 0 -> 9223372036854775809 [valid, matches]
+ 9223372036854775808 1 -> 9223372036854775810 [valid, matches]
+ 9223372036854775808 62 -> 13835058055282163712 [valid, matches]
+ 9223372036854775808 63 -> 9223372036854775808 [valid, matches]
+ 9223372036854775808 64 -> 27670116110564327424 [valid, matches]
+ 9223372036854775809 0 -> 9223372036854775809 [valid, matches]
+ 9223372036854775809 1 -> 9223372036854775811 [valid, matches]
+ 9223372036854775809 62 -> 13835058055282163713 [valid, matches]
+ 9223372036854775809 63 -> 9223372036854775809 [valid, matches]
+ 9223372036854775809 64 -> 27670116110564327425 [valid, matches]
+
+clearBit
+ -9223372036854775810 0 -> -9223372036854775810 [valid, matches]
+ -9223372036854775810 1 -> -9223372036854775812 [valid, matches]
+ -9223372036854775810 62 -> -13835058055282163714 [valid, matches]
+ -9223372036854775810 63 -> -9223372036854775810 [valid, matches]
+ -9223372036854775810 64 -> -27670116110564327426 [valid, matches]
+ -9223372036854775809 0 -> -9223372036854775810 [valid, matches]
+ -9223372036854775809 1 -> -9223372036854775811 [valid, matches]
+ -9223372036854775809 62 -> -13835058055282163713 [valid, matches]
+ -9223372036854775809 63 -> -9223372036854775809 [valid, matches]
+ -9223372036854775809 64 -> -27670116110564327425 [valid, matches]
+ -9223372036854775808 0 -> -9223372036854775808 [valid, matches]
+ -9223372036854775808 1 -> -9223372036854775808 [valid, matches]
+ -9223372036854775808 62 -> -9223372036854775808 [valid, matches]
+ -9223372036854775808 63 -> -18446744073709551616 [valid, matches]
+ -9223372036854775808 64 -> -27670116110564327424 [valid, matches]
+ -9223372036854775807 0 -> -9223372036854775808 [valid, matches]
+ -9223372036854775807 1 -> -9223372036854775807 [valid, matches]
+ -9223372036854775807 62 -> -9223372036854775807 [valid, matches]
+ -9223372036854775807 63 -> -18446744073709551615 [valid, matches]
+ -9223372036854775807 64 -> -27670116110564327423 [valid, matches]
+ -9223372036854775806 0 -> -9223372036854775806 [valid, matches]
+ -9223372036854775806 1 -> -9223372036854775808 [valid, matches]
+ -9223372036854775806 62 -> -9223372036854775806 [valid, matches]
+ -9223372036854775806 63 -> -18446744073709551614 [valid, matches]
+ -9223372036854775806 64 -> -27670116110564327422 [valid, matches]
+ -2147483650 0 -> -2147483650 [valid, matches]
+ -2147483650 1 -> -2147483652 [valid, matches]
+ -2147483650 62 -> -4611686020574871554 [valid, matches]
+ -2147483650 63 -> -9223372039002259458 [valid, matches]
+ -2147483650 64 -> -18446744075857035266 [valid, matches]
+ -2147483649 0 -> -2147483650 [valid, matches]
+ -2147483649 1 -> -2147483651 [valid, matches]
+ -2147483649 62 -> -4611686020574871553 [valid, matches]
+ -2147483649 63 -> -9223372039002259457 [valid, matches]
+ -2147483649 64 -> -18446744075857035265 [valid, matches]
+ -2147483648 0 -> -2147483648 [valid, matches]
+ -2147483648 1 -> -2147483648 [valid, matches]
+ -2147483648 62 -> -4611686020574871552 [valid, matches]
+ -2147483648 63 -> -9223372039002259456 [valid, matches]
+ -2147483648 64 -> -18446744075857035264 [valid, matches]
+ -2147483647 0 -> -2147483648 [valid, matches]
+ -2147483647 1 -> -2147483647 [valid, matches]
+ -2147483647 62 -> -4611686020574871551 [valid, matches]
+ -2147483647 63 -> -9223372039002259455 [valid, matches]
+ -2147483647 64 -> -18446744075857035263 [valid, matches]
+ -2147483646 0 -> -2147483646 [valid, matches]
+ -2147483646 1 -> -2147483648 [valid, matches]
+ -2147483646 62 -> -4611686020574871550 [valid, matches]
+ -2147483646 63 -> -9223372039002259454 [valid, matches]
+ -2147483646 64 -> -18446744075857035262 [valid, matches]
+ -2 0 -> -2 [valid, matches]
+ -2 1 -> -4 [valid, matches]
+ -2 62 -> -4611686018427387906 [valid, matches]
+ -2 63 -> -9223372036854775810 [valid, matches]
+ -2 64 -> -18446744073709551618 [valid, matches]
+ -1 0 -> -2 [valid, matches]
+ -1 1 -> -3 [valid, matches]
+ -1 62 -> -4611686018427387905 [valid, matches]
+ -1 63 -> -9223372036854775809 [valid, matches]
+ -1 64 -> -18446744073709551617 [valid, matches]
+ 0 0 -> 0 [valid, matches]
+ 0 1 -> 0 [valid, matches]
+ 0 62 -> 0 [valid, matches]
+ 0 63 -> 0 [valid, matches]
+ 0 64 -> 0 [valid, matches]
+ 1 0 -> 0 [valid, matches]
+ 1 1 -> 1 [valid, matches]
+ 1 62 -> 1 [valid, matches]
+ 1 63 -> 1 [valid, matches]
+ 1 64 -> 1 [valid, matches]
+ 2 0 -> 2 [valid, matches]
+ 2 1 -> 0 [valid, matches]
+ 2 62 -> 2 [valid, matches]
+ 2 63 -> 2 [valid, matches]
+ 2 64 -> 2 [valid, matches]
+ 2147483645 0 -> 2147483644 [valid, matches]
+ 2147483645 1 -> 2147483645 [valid, matches]
+ 2147483645 62 -> 2147483645 [valid, matches]
+ 2147483645 63 -> 2147483645 [valid, matches]
+ 2147483645 64 -> 2147483645 [valid, matches]
+ 2147483646 0 -> 2147483646 [valid, matches]
+ 2147483646 1 -> 2147483644 [valid, matches]
+ 2147483646 62 -> 2147483646 [valid, matches]
+ 2147483646 63 -> 2147483646 [valid, matches]
+ 2147483646 64 -> 2147483646 [valid, matches]
+ 2147483647 0 -> 2147483646 [valid, matches]
+ 2147483647 1 -> 2147483645 [valid, matches]
+ 2147483647 62 -> 2147483647 [valid, matches]
+ 2147483647 63 -> 2147483647 [valid, matches]
+ 2147483647 64 -> 2147483647 [valid, matches]
+ 2147483648 0 -> 2147483648 [valid, matches]
+ 2147483648 1 -> 2147483648 [valid, matches]
+ 2147483648 62 -> 2147483648 [valid, matches]
+ 2147483648 63 -> 2147483648 [valid, matches]
+ 2147483648 64 -> 2147483648 [valid, matches]
+ 2147483649 0 -> 2147483648 [valid, matches]
+ 2147483649 1 -> 2147483649 [valid, matches]
+ 2147483649 62 -> 2147483649 [valid, matches]
+ 2147483649 63 -> 2147483649 [valid, matches]
+ 2147483649 64 -> 2147483649 [valid, matches]
+ 9223372036854775805 0 -> 9223372036854775804 [valid, matches]
+ 9223372036854775805 1 -> 9223372036854775805 [valid, matches]
+ 9223372036854775805 62 -> 4611686018427387901 [valid, matches]
+ 9223372036854775805 63 -> 9223372036854775805 [valid, matches]
+ 9223372036854775805 64 -> 9223372036854775805 [valid, matches]
+ 9223372036854775806 0 -> 9223372036854775806 [valid, matches]
+ 9223372036854775806 1 -> 9223372036854775804 [valid, matches]
+ 9223372036854775806 62 -> 4611686018427387902 [valid, matches]
+ 9223372036854775806 63 -> 9223372036854775806 [valid, matches]
+ 9223372036854775806 64 -> 9223372036854775806 [valid, matches]
+ 9223372036854775807 0 -> 9223372036854775806 [valid, matches]
+ 9223372036854775807 1 -> 9223372036854775805 [valid, matches]
+ 9223372036854775807 62 -> 4611686018427387903 [valid, matches]
+ 9223372036854775807 63 -> 9223372036854775807 [valid, matches]
+ 9223372036854775807 64 -> 9223372036854775807 [valid, matches]
+ 9223372036854775808 0 -> 9223372036854775808 [valid, matches]
+ 9223372036854775808 1 -> 9223372036854775808 [valid, matches]
+ 9223372036854775808 62 -> 9223372036854775808 [valid, matches]
+ 9223372036854775808 63 -> 0 [valid, matches]
+ 9223372036854775808 64 -> 9223372036854775808 [valid, matches]
+ 9223372036854775809 0 -> 9223372036854775808 [valid, matches]
+ 9223372036854775809 1 -> 9223372036854775809 [valid, matches]
+ 9223372036854775809 62 -> 9223372036854775809 [valid, matches]
+ 9223372036854775809 63 -> 1 [valid, matches]
+ 9223372036854775809 64 -> 9223372036854775809 [valid, matches]
+
+complementBit
+ -9223372036854775810 0 -> -9223372036854775809 [valid, matches]
+ -9223372036854775810 1 -> -9223372036854775812 [valid, matches]
+ -9223372036854775810 62 -> -13835058055282163714 [valid, matches]
+ -9223372036854775810 63 -> -2 [valid, matches]
+ -9223372036854775810 64 -> -27670116110564327426 [valid, matches]
+ -9223372036854775809 0 -> -9223372036854775810 [valid, matches]
+ -9223372036854775809 1 -> -9223372036854775811 [valid, matches]
+ -9223372036854775809 62 -> -13835058055282163713 [valid, matches]
+ -9223372036854775809 63 -> -1 [valid, matches]
+ -9223372036854775809 64 -> -27670116110564327425 [valid, matches]
+ -9223372036854775808 0 -> -9223372036854775807 [valid, matches]
+ -9223372036854775808 1 -> -9223372036854775806 [valid, matches]
+ -9223372036854775808 62 -> -4611686018427387904 [valid, matches]
+ -9223372036854775808 63 -> -18446744073709551616 [valid, matches]
+ -9223372036854775808 64 -> -27670116110564327424 [valid, matches]
+ -9223372036854775807 0 -> -9223372036854775808 [valid, matches]
+ -9223372036854775807 1 -> -9223372036854775805 [valid, matches]
+ -9223372036854775807 62 -> -4611686018427387903 [valid, matches]
+ -9223372036854775807 63 -> -18446744073709551615 [valid, matches]
+ -9223372036854775807 64 -> -27670116110564327423 [valid, matches]
+ -9223372036854775806 0 -> -9223372036854775805 [valid, matches]
+ -9223372036854775806 1 -> -9223372036854775808 [valid, matches]
+ -9223372036854775806 62 -> -4611686018427387902 [valid, matches]
+ -9223372036854775806 63 -> -18446744073709551614 [valid, matches]
+ -9223372036854775806 64 -> -27670116110564327422 [valid, matches]
+ -2147483650 0 -> -2147483649 [valid, matches]
+ -2147483650 1 -> -2147483652 [valid, matches]
+ -2147483650 62 -> -4611686020574871554 [valid, matches]
+ -2147483650 63 -> -9223372039002259458 [valid, matches]
+ -2147483650 64 -> -18446744075857035266 [valid, matches]
+ -2147483649 0 -> -2147483650 [valid, matches]
+ -2147483649 1 -> -2147483651 [valid, matches]
+ -2147483649 62 -> -4611686020574871553 [valid, matches]
+ -2147483649 63 -> -9223372039002259457 [valid, matches]
+ -2147483649 64 -> -18446744075857035265 [valid, matches]
+ -2147483648 0 -> -2147483647 [valid, matches]
+ -2147483648 1 -> -2147483646 [valid, matches]
+ -2147483648 62 -> -4611686020574871552 [valid, matches]
+ -2147483648 63 -> -9223372039002259456 [valid, matches]
+ -2147483648 64 -> -18446744075857035264 [valid, matches]
+ -2147483647 0 -> -2147483648 [valid, matches]
+ -2147483647 1 -> -2147483645 [valid, matches]
+ -2147483647 62 -> -4611686020574871551 [valid, matches]
+ -2147483647 63 -> -9223372039002259455 [valid, matches]
+ -2147483647 64 -> -18446744075857035263 [valid, matches]
+ -2147483646 0 -> -2147483645 [valid, matches]
+ -2147483646 1 -> -2147483648 [valid, matches]
+ -2147483646 62 -> -4611686020574871550 [valid, matches]
+ -2147483646 63 -> -9223372039002259454 [valid, matches]
+ -2147483646 64 -> -18446744075857035262 [valid, matches]
+ -2 0 -> -1 [valid, matches]
+ -2 1 -> -4 [valid, matches]
+ -2 62 -> -4611686018427387906 [valid, matches]
+ -2 63 -> -9223372036854775810 [valid, matches]
+ -2 64 -> -18446744073709551618 [valid, matches]
+ -1 0 -> -2 [valid, matches]
+ -1 1 -> -3 [valid, matches]
+ -1 62 -> -4611686018427387905 [valid, matches]
+ -1 63 -> -9223372036854775809 [valid, matches]
+ -1 64 -> -18446744073709551617 [valid, matches]
+ 0 0 -> 1 [valid, matches]
+ 0 1 -> 2 [valid, matches]
+ 0 62 -> 4611686018427387904 [valid, matches]
+ 0 63 -> 9223372036854775808 [valid, matches]
+ 0 64 -> 18446744073709551616 [valid, matches]
+ 1 0 -> 0 [valid, matches]
+ 1 1 -> 3 [valid, matches]
+ 1 62 -> 4611686018427387905 [valid, matches]
+ 1 63 -> 9223372036854775809 [valid, matches]
+ 1 64 -> 18446744073709551617 [valid, matches]
+ 2 0 -> 3 [valid, matches]
+ 2 1 -> 0 [valid, matches]
+ 2 62 -> 4611686018427387906 [valid, matches]
+ 2 63 -> 9223372036854775810 [valid, matches]
+ 2 64 -> 18446744073709551618 [valid, matches]
+ 2147483645 0 -> 2147483644 [valid, matches]
+ 2147483645 1 -> 2147483647 [valid, matches]
+ 2147483645 62 -> 4611686020574871549 [valid, matches]
+ 2147483645 63 -> 9223372039002259453 [valid, matches]
+ 2147483645 64 -> 18446744075857035261 [valid, matches]
+ 2147483646 0 -> 2147483647 [valid, matches]
+ 2147483646 1 -> 2147483644 [valid, matches]
+ 2147483646 62 -> 4611686020574871550 [valid, matches]
+ 2147483646 63 -> 9223372039002259454 [valid, matches]
+ 2147483646 64 -> 18446744075857035262 [valid, matches]
+ 2147483647 0 -> 2147483646 [valid, matches]
+ 2147483647 1 -> 2147483645 [valid, matches]
+ 2147483647 62 -> 4611686020574871551 [valid, matches]
+ 2147483647 63 -> 9223372039002259455 [valid, matches]
+ 2147483647 64 -> 18446744075857035263 [valid, matches]
+ 2147483648 0 -> 2147483649 [valid, matches]
+ 2147483648 1 -> 2147483650 [valid, matches]
+ 2147483648 62 -> 4611686020574871552 [valid, matches]
+ 2147483648 63 -> 9223372039002259456 [valid, matches]
+ 2147483648 64 -> 18446744075857035264 [valid, matches]
+ 2147483649 0 -> 2147483648 [valid, matches]
+ 2147483649 1 -> 2147483651 [valid, matches]
+ 2147483649 62 -> 4611686020574871553 [valid, matches]
+ 2147483649 63 -> 9223372039002259457 [valid, matches]
+ 2147483649 64 -> 18446744075857035265 [valid, matches]
+ 9223372036854775805 0 -> 9223372036854775804 [valid, matches]
+ 9223372036854775805 1 -> 9223372036854775807 [valid, matches]
+ 9223372036854775805 62 -> 4611686018427387901 [valid, matches]
+ 9223372036854775805 63 -> 18446744073709551613 [valid, matches]
+ 9223372036854775805 64 -> 27670116110564327421 [valid, matches]
+ 9223372036854775806 0 -> 9223372036854775807 [valid, matches]
+ 9223372036854775806 1 -> 9223372036854775804 [valid, matches]
+ 9223372036854775806 62 -> 4611686018427387902 [valid, matches]
+ 9223372036854775806 63 -> 18446744073709551614 [valid, matches]
+ 9223372036854775806 64 -> 27670116110564327422 [valid, matches]
+ 9223372036854775807 0 -> 9223372036854775806 [valid, matches]
+ 9223372036854775807 1 -> 9223372036854775805 [valid, matches]
+ 9223372036854775807 62 -> 4611686018427387903 [valid, matches]
+ 9223372036854775807 63 -> 18446744073709551615 [valid, matches]
+ 9223372036854775807 64 -> 27670116110564327423 [valid, matches]
+ 9223372036854775808 0 -> 9223372036854775809 [valid, matches]
+ 9223372036854775808 1 -> 9223372036854775810 [valid, matches]
+ 9223372036854775808 62 -> 13835058055282163712 [valid, matches]
+ 9223372036854775808 63 -> 0 [valid, matches]
+ 9223372036854775808 64 -> 27670116110564327424 [valid, matches]
+ 9223372036854775809 0 -> 9223372036854775808 [valid, matches]
+ 9223372036854775809 1 -> 9223372036854775811 [valid, matches]
+ 9223372036854775809 62 -> 13835058055282163713 [valid, matches]
+ 9223372036854775809 63 -> 1 [valid, matches]
+ 9223372036854775809 64 -> 27670116110564327425 [valid, matches]
+
=====================================
testsuite/tests/numeric/should_run/all.T
=====================================
@@ -101,3 +101,4 @@ test('T24245', normal, compile_and_run, [''])
test('T25653', normal, compile_and_run, [''])
test('T18619', exit_code(1), compile_and_run, [''])
test('T26230', normal, compile_and_run, [''])
+test('T21176', normal, compile_and_run, [''])
=====================================
testsuite/tests/simplCore/should_compile/T8832.hs
=====================================
@@ -23,3 +23,9 @@ T(w32,Word32)
T(w64,Word64)
T(z,Integer)
+
+zset :: Integer
+zset = setBit (bit 0) 0
+
+zcompl :: Integer
+zcompl = complementBit (bit 0) 0
=====================================
testsuite/tests/simplCore/should_compile/T8832.stdout
=====================================
@@ -8,4 +8,6 @@ w8 = GHC.Internal.Word.W8# 0#Word8
w16 = GHC.Internal.Word.W16# 0#Word16
w32 = GHC.Internal.Word.W32# 0#Word32
w64 = GHC.Internal.Word.W64# 0#Word64
-z = GHC.Internal.Bignum.Integer.IS 0#
+zcompl = GHC.Internal.Bignum.Integer.IS 0#
+zset = GHC.Internal.Bignum.Integer.IS 1#
+z = zcompl
=====================================
utils/check-exact/Main.hs
=====================================
@@ -646,7 +646,7 @@ addLocaLDecl3 :: Changer
addLocaLDecl3 libdir top = do
Right newDecl <- withDynFlags libdir (\df -> parseDecl df "decl" "nn = 2")
let
- doAddLocal = replaceDecls (anchorEof lp) [parent',d2']
+ doAddLocal = replaceDecls (addModuleCommentOrigDeltas lp) [parent',d2']
where
lp = top
(de1:d2:_) = hsDecls lp
@@ -667,7 +667,7 @@ addLocaLDecl4 libdir lp = do
Right newDecl <- withDynFlags libdir (\df -> parseDecl df "decl" "nn = 2")
Right newSig <- withDynFlags libdir (\df -> parseDecl df "sig" "nn :: Int")
let
- doAddLocal = replaceDecls (anchorEof lp) (parent':ds)
+ doAddLocal = replaceDecls (addModuleCommentOrigDeltas lp) (parent':ds)
where
(parent:ds) = hsDecls (makeDeltaAst lp)
@@ -781,7 +781,7 @@ rmDecl3 _libdir lp = do
rmDecl4 :: Changer
rmDecl4 _libdir lp = do
let
- doRmDecl = replaceDecls (anchorEof lp) [de1',sd1]
+ doRmDecl = replaceDecls (addModuleCommentOrigDeltas lp) [de1',sd1]
where
[de1] = hsDecls lp
(de1',Just sd1) = modifyValD (getLocA de1) de1 $ \_m [sd1a,sd2] ->
=====================================
utils/check-exact/Transform.hs
=====================================
@@ -65,7 +65,7 @@ module Transform
, balanceComments
, balanceCommentsList
, balanceCommentsListA
- , anchorEof
+ , addModuleCommentOrigDeltas
-- ** Managing lists, pure functions
, captureOrderBinds
@@ -724,8 +724,8 @@ balanceSameLineComments (L la (Match anm mctxt pats (GRHSs x grhss lb)))
-- ---------------------------------------------------------------------
-anchorEof :: ParsedSource -> ParsedSource
-anchorEof (L l m@(HsModule (XModulePs an _lo _ _) _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } })
+addModuleCommentOrigDeltas :: ParsedSource -> ParsedSource
+addModuleCommentOrigDeltas (L l m@(HsModule (XModulePs an _lo _ _) _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } })
where
an' = addCommentOrigDeltasAnn an
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca4a699ffefb5cfc6784097a51fb735...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca4a699ffefb5cfc6784097a51fb735...
You're receiving this email because of your account on gitlab.haskell.org.