[Git][ghc/ghc][wip/inline1-for-compareInt-and-compareWord] Add INLINE [1] pragma to compareInt / compareWord

Bodigrim (@Bodigrim) gitlab at gitlab.haskell.org
Fri Jun 21 22:00:58 UTC 2024



Bodigrim pushed to branch wip/inline1-for-compareInt-and-compareWord at Glasgow Haskell Compiler / GHC


Commits:
456d055c by Alexander McKenna at 2024-06-21T23:00:49+01:00
Add INLINE [1] pragma to compareInt / compareWord

To allow rules to be written on the concrete implementation of
`compare` for `Int` and `Word`, we need to have an `INLINE [1]`
pragma on these functions, following the
`matching_overloaded_methods_in_rules` note in `GHC.Classes`.

CLC proposal https://github.com/haskell/core-libraries-committee/issues/179

Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/22643

- - - - -


2 changed files:

- libraries/base/changelog.md
- libraries/ghc-prim/GHC/Classes.hs


Changes:

=====================================
libraries/base/changelog.md
=====================================
@@ -2,6 +2,7 @@
 
 ## 4.21.0.0 *TBA*
   * Add a `readTixFile` field to the `HpcFlags` record in `GHC.RTS.Flags` ([CLC proposal #276](https://github.com/haskell/core-libraries-committee/issues/276))
+  * Add `INLINE[1]` to `compareInt` / `compareWord` ([CLC proposal #179](https://github.com/haskell/core-libraries-committee/issues/179))
   * Add the `MonadFix` instance for `(,) a`, similar to the one for `Writer a` ([CLC proposal #238](https://github.com/haskell/core-libraries-committee/issues/238))
   * Improve `toInteger :: Word32 -> Integer` on 64-bit platforms ([CLC proposal #259](https://github.com/haskell/core-libraries-committee/issues/259))
   * Make `flip` representation polymorphic ([CLC proposal #245](https://github.com/haskell/core-libraries-committee/issues/245))


=====================================
libraries/ghc-prim/GHC/Classes.hs
=====================================
@@ -575,6 +575,8 @@ gtInt, geInt, ltInt, leInt :: Int -> Int -> Bool
 (I# x) `ltInt` (I# y) = isTrue# (x <#  y)
 (I# x) `leInt` (I# y) = isTrue# (x <=# y)
 
+-- See GHC.Classes#matching_overloaded_methods_in_rules
+{-# INLINE [1] compareInt #-}
 compareInt :: Int -> Int -> Ordering
 (I# x#) `compareInt` (I# y#) = compareInt# x# y#
 
@@ -602,6 +604,8 @@ gtWord, geWord, ltWord, leWord :: Word -> Word -> Bool
 (W# x) `ltWord` (W# y) = isTrue# (x `ltWord#` y)
 (W# x) `leWord` (W# y) = isTrue# (x `leWord#` y)
 
+-- See GHC.Classes#matching_overloaded_methods_in_rules
+{-# INLINE [1] compareWord #-}
 compareWord :: Word -> Word -> Ordering
 (W# x#) `compareWord` (W# y#) = compareWord# x# y#
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/456d055c4d47ae9d6f84dd7809f1658544b16ad1

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/456d055c4d47ae9d6f84dd7809f1658544b16ad1
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/20240621/18768bbc/attachment-0001.html>


More information about the ghc-commits mailing list