[Git][ghc/ghc][wip/T23576] Add AllowBigQuot option to StgToCmm

Jaro Reinders (@Noughtmare) gitlab at gitlab.haskell.org
Fri Jun 30 14:26:09 UTC 2023



Jaro Reinders pushed to branch wip/T23576 at Glasgow Haskell Compiler / GHC


Commits:
5c659c69 by Jaro Reinders at 2023-06-30T16:26:04+02:00
Add AllowBigQuot option to StgToCmm

- - - - -


3 changed files:

- compiler/GHC/Driver/Config/StgToCmm.hs
- compiler/GHC/StgToCmm/Config.hs
- compiler/GHC/StgToCmm/Prim.hs


Changes:

=====================================
compiler/GHC/Driver/Config/StgToCmm.hs
=====================================
@@ -51,6 +51,7 @@ initStgToCmmConfig dflags mod = StgToCmmConfig
   , stgToCmmDoTagCheck    = gopt Opt_DoTagInferenceChecks  dflags
   -- backend flags
   , stgToCmmAllowBigArith             = not ncg || platformArch platform == ArchWasm32 || platformArch platform == ArchX86
+  , stgToCmmAllowBigQuot              = not ncg || platformArch platform == ArchWasm32
   , stgToCmmAllowQuotRemInstr         = ncg  && (x86ish || ppc)
   , stgToCmmAllowQuotRem2             = (ncg && (x86ish || ppc)) || llvm
   , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm


=====================================
compiler/GHC/StgToCmm/Config.hs
=====================================
@@ -63,6 +63,7 @@ data StgToCmmConfig = StgToCmmConfig
   , stgToCmmDoTagCheck     :: !Bool              -- ^ Verify tag inference predictions.
   ------------------------------ Backend Flags ----------------------------------
   , stgToCmmAllowBigArith             :: !Bool   -- ^ Allowed to emit larger than native size arithmetic (only LLVM and C backends)
+  , stgToCmmAllowBigQuot              :: !Bool   -- ^ Allowed to emit larger than native size division operations
   , stgToCmmAllowQuotRemInstr         :: !Bool   -- ^ Allowed to generate QuotRem instructions
   , stgToCmmAllowQuotRem2             :: !Bool   -- ^ Allowed to generate QuotRem
   , stgToCmmAllowExtendedAddSubInstrs :: !Bool   -- ^ Allowed to generate AddWordC, SubWordC, Add2, etc.


=====================================
compiler/GHC/StgToCmm/Prim.hs
=====================================
@@ -1679,6 +1679,13 @@ emitPrimOp cfg primop =
     let stmt = mkAssign (CmmLocal res) (CmmMachOp mop args)
     emit stmt
 
+  isQuottishOp :: CallishMachOp -> Bool
+  isQuottishOp MO_I64_Quot = True
+  isQuottishOp MO_I64_Rem = True
+  isQuottishOp MO_W64_Quot = True
+  isQuottishOp MO_W64_Rem = True
+  isQuottishOp _ = False
+
   opTranslate64
     :: [CmmExpr]
     -> (Width -> MachOp)
@@ -1687,7 +1694,8 @@ emitPrimOp cfg primop =
   opTranslate64 args mkMop callish =
     case platformWordSize platform of
       -- LLVM and C `can handle larger than native size arithmetic natively.
-      _ | stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64
+      _ | not (isQuottishOp callish), stgToCmmAllowBigArith cfg -> opTranslate args $ mkMop W64
+        | isQuottishOp callish, stgToCmmAllowBigQuot cfg -> opTranslate args $ mkMop W64
       PW4 -> opCallish args callish
       PW8 -> opTranslate args $ mkMop W64
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c659c69f24e6264ee7b5c355ddaa48a643a3220

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c659c69f24e6264ee7b5c355ddaa48a643a3220
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/20230630/90536883/attachment-0001.html>


More information about the ghc-commits mailing list