[Git][ghc/ghc][wip/backports] 3 commits: Bump Cabal submodule
Ben Gamari
gitlab at gitlab.haskell.org
Tue Aug 25 01:36:43 UTC 2020
Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC
Commits:
8c7e8e1c by Ben Gamari at 2020-08-17T20:09:30+00:00
Bump Cabal submodule
- - - - -
1f6824a1 by Ben Gamari at 2020-08-21T11:35:00-04:00
Accept spurious performance shift
Metric Decrease:
T13035
- - - - -
5ccf44c6 by Krzysztof Gogolewski at 2020-08-24T21:35:48-04:00
Fix types in silly shifts (#18589)
Patch written by Simon. I have only added a testcase.
(cherry picked from commit 364258e0ad25bc95e69745554f5ca831ce80baf8)
- - - - -
8 changed files:
- compiler/GHC/Core/Opt/ConstantFold.hs
- libraries/Cabal
- + testsuite/tests/simplCore/should_compile/T18589.hs
- testsuite/tests/simplCore/should_compile/all.T
- utils/check-api-annotations/check-api-annotations.cabal
- utils/check-ppr/check-ppr.cabal
- utils/ghc-cabal/ghc-cabal.cabal
- utils/ghc-cabal/ghc.mk
Changes:
=====================================
compiler/GHC/Core/Opt/ConstantFold.hs
=====================================
@@ -140,11 +140,11 @@ primOpRules nm = \case
, inversePrimOp NotIOp ]
IntNegOp -> mkPrimOpRule nm 1 [ unaryLit negOp
, inversePrimOp IntNegOp ]
- ISllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL)
+ ISllOp -> mkPrimOpRule nm 2 [ shiftRule LitNumInt (const Bits.shiftL)
, rightIdentityPlatform zeroi ]
- ISraOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftR)
+ ISraOp -> mkPrimOpRule nm 2 [ shiftRule LitNumInt (const Bits.shiftR)
, rightIdentityPlatform zeroi ]
- ISrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical
+ ISrlOp -> mkPrimOpRule nm 2 [ shiftRule LitNumInt shiftRightLogical
, rightIdentityPlatform zeroi ]
-- Word operations
@@ -186,8 +186,8 @@ primOpRules nm = \case
, equalArgs >> retLit zerow ]
NotOp -> mkPrimOpRule nm 1 [ unaryLit complementOp
, inversePrimOp NotOp ]
- SllOp -> mkPrimOpRule nm 2 [ shiftRule (const Bits.shiftL) ]
- SrlOp -> mkPrimOpRule nm 2 [ shiftRule shiftRightLogical ]
+ SllOp -> mkPrimOpRule nm 2 [ shiftRule LitNumWord (const Bits.shiftL) ]
+ SrlOp -> mkPrimOpRule nm 2 [ shiftRule LitNumWord shiftRightLogical ]
-- coercions
Word2IntOp -> mkPrimOpRule nm 1 [ liftLitPlatform word2IntLit
@@ -474,12 +474,14 @@ wordOpC2 op env (LitNumber LitNumWord w1) (LitNumber LitNumWord w2) =
wordCResult (roPlatform env) (fromInteger w1 `op` fromInteger w2)
wordOpC2 _ _ _ _ = Nothing
-shiftRule :: (Platform -> Integer -> Int -> Integer) -> RuleM CoreExpr
+shiftRule :: LitNumType -- Type of the result, either LitNumInt or LitNumWord
+ -> (Platform -> Integer -> Int -> Integer)
+ -> RuleM CoreExpr
-- Shifts take an Int; hence third arg of op is Int
-- Used for shift primops
--- ISllOp, ISraOp, ISrlOp :: Word# -> Int# -> Word#
+-- ISllOp, ISraOp, ISrlOp :: Int# -> Int# -> Int#
-- SllOp, SrlOp :: Word# -> Int# -> Word#
-shiftRule shift_op
+shiftRule lit_num_ty shift_op
= do { platform <- getPlatform
; [e1, Lit (LitNumber LitNumInt shift_len)] <- getArgs
; case e1 of
@@ -487,7 +489,9 @@ shiftRule shift_op
-> return e1
-- See Note [Guarding against silly shifts]
| shift_len < 0 || shift_len > toInteger (platformWordSizeInBits platform)
- -> return $ Lit $ mkLitNumberWrap platform LitNumInt 0
+ -> return $ Lit $ mkLitNumberWrap platform lit_num_ty 0
+ -- Be sure to use lit_num_ty here, so we get a correctly typed zero
+ -- of type Int# or Word# resp. See #18589
-- Do the shift at type Integer, but shift length is Int
Lit (LitNumber nt x)
=====================================
libraries/Cabal
=====================================
@@ -1 +1 @@
-Subproject commit 32dad5c1cf70d65ecb93b0ec214445cf9c9f6615
+Subproject commit 1d886476c443b227bf93eba62781a6cad5012d9e
=====================================
testsuite/tests/simplCore/should_compile/T18589.hs
=====================================
@@ -0,0 +1,12 @@
+{-# LANGUAGE MagicHash #-}
+module T18589 where
+
+import GHC.Prim
+
+-- See Note [Guarding against silly shifts]
+-- Make sure that a silly shift is optimized correctly
+f1 x = uncheckedIShiftL# x -1#
+f2 x = uncheckedIShiftRA# x -1#
+f3 x = uncheckedIShiftRL# x -1#
+f4 x = uncheckedShiftL# x -1#
+f5 x = uncheckedShiftRL# x -1#
=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -332,3 +332,4 @@ test('T18328', [ only_ways(['optasm']), grep_errmsg(r'Arity=') ], compile, ['-dd
test('T18347', normal, compile, ['-dcore-lint -O'])
test('T18355', [ grep_errmsg(r'OneShot') ], compile, ['-O -ddump-simpl -dsuppress-uniques'])
test('T18399', normal, compile, ['-dcore-lint -O'])
+test('T18589', normal, compile, ['-dcore-lint -O'])
=====================================
utils/check-api-annotations/check-api-annotations.cabal
=====================================
@@ -24,6 +24,6 @@ Executable check-api-annotations
Build-Depends: base >= 4 && < 5,
containers,
- Cabal >= 3.0 && < 3.4,
+ Cabal >= 3.0 && < 3.6,
directory,
ghc
=====================================
utils/check-ppr/check-ppr.cabal
=====================================
@@ -25,7 +25,7 @@ Executable check-ppr
Build-Depends: base >= 4 && < 5,
bytestring,
containers,
- Cabal >= 3.0 && < 3.4,
+ Cabal >= 3.0 && < 3.6,
directory,
filepath,
ghc
=====================================
utils/ghc-cabal/ghc-cabal.cabal
=====================================
@@ -21,6 +21,6 @@ Executable ghc-cabal
Build-Depends: base >= 3 && < 5,
bytestring >= 0.10 && < 0.11,
- Cabal >= 3.0 && < 3.4,
+ Cabal >= 3.2 && < 3.6,
directory >= 1.1 && < 1.4,
filepath >= 1.2 && < 1.5
=====================================
utils/ghc-cabal/ghc.mk
=====================================
@@ -37,25 +37,13 @@ ifneq "$(BINDIST)" "YES"
$(ghc-cabal_INPLACE) : $(ghc-cabal_DIST_BINARY) | $$(dir $$@)/.
"$(CP)" $< $@
-# Minor hack, since we can't reuse the `hs-suffix-rules-srcdir` macro
-ifneq ($(wildcard libraries/Cabal/Cabal/Distribution/Fields/Lexer.x),)
-# Lexer.x exists so we have to call Alex ourselves
-CABAL_LEXER_DEP := bootstrapping/Cabal/Distribution/Fields/Lexer.hs
-
-bootstrapping/Cabal/Distribution/Fields/Lexer.hs: libraries/Cabal/Cabal/Distribution/Fields/Lexer.x
- mkdir -p bootstrapping/Cabal/Distribution/Fields
- $(call cmd,ALEX) $< -o $@
-else
-CABAL_LEXER_DEP := libraries/Cabal/Cabal/Distribution/Fields/Lexer.hs
-endif
-
-$(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*/*.hs)
-$(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs)
-$(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs)
+$(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/src/Distribution/*/*/*.hs)
+$(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/src/Distribution/*/*.hs)
+$(ghc-cabal_DIST_BINARY): $(wildcard libraries/Cabal/Cabal/src/Distribution/*.hs)
# N.B. Compile with -O0 since this is not a performance-critical executable
# and the Cabal takes nearly twice as long to build with -O1. See #16817.
-$(ghc-cabal_DIST_BINARY): $(CABAL_LEXER_DEP) utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
+$(ghc-cabal_DIST_BINARY): utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
"$(GHC)" $(SRC_HC_OPTS) \
$(addprefix -optc, $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE0)) \
$(addprefix -optl, $(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE0)) \
@@ -69,8 +57,7 @@ $(ghc-cabal_DIST_BINARY): $(CABAL_LEXER_DEP) utils/ghc-cabal/Main.hs $(TOUCH_DEP
-DBOOTSTRAPPING \
-odir bootstrapping \
-hidir bootstrapping \
- $(CABAL_LEXER_DEP) \
- -ilibraries/Cabal/Cabal \
+ -ilibraries/Cabal/Cabal/src \
-ilibraries/binary/src \
-ilibraries/filepath \
-ilibraries/hpc \
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5db922952e7fcd2a4f2562112769f352c60d30e...5ccf44c6f0e27e83bf2828f0834bb790b1834929
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5db922952e7fcd2a4f2562112769f352c60d30e...5ccf44c6f0e27e83bf2828f0834bb790b1834929
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200824/467c39db/attachment-0001.html>
More information about the ghc-commits
mailing list