[commit: ghc] master: Fix a bug in unboxed sum layout generation (e79bb2c)

git at git.haskell.org git at git.haskell.org
Tue Aug 9 22:32:14 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e79bb2c10d66ec8f0c037e66c7d0a22aa887fdc1/ghc

>---------------------------------------------------------------

commit e79bb2c10d66ec8f0c037e66c7d0a22aa887fdc1
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Tue Aug 9 22:30:56 2016 +0000

    Fix a bug in unboxed sum layout generation
    
    We need to maintain the invariant that the layout fields are always sorted.
    
    Two tests that were previously broken are added.


>---------------------------------------------------------------

e79bb2c10d66ec8f0c037e66c7d0a22aa887fdc1
 compiler/simplStg/RepType.hs                          |  4 +++-
 testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/compiler/simplStg/RepType.hs b/compiler/simplStg/RepType.hs
index 7e42a86..ca8438e 100644
--- a/compiler/simplStg/RepType.hs
+++ b/compiler/simplStg/RepType.hs
@@ -199,7 +199,9 @@ ubxSumRepType constrs0 =
       | Just s' <- s `fitsIn` es
       = -- found a slot, use it
         s' : merge ess ss
-
+      | s < es
+      = -- we need a new slot and this is the right place for it
+        s : merge (es : ess) ss
       | otherwise
       = -- keep searching for a slot
         es : merge ess (s : ss)
diff --git a/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs b/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
index 5c0b929..399e074 100644
--- a/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
+++ b/testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
@@ -42,7 +42,7 @@ uniq_tests = do
 
 layout_tests :: IO ()
 layout_tests = sequence_
-    [ layout1, layout2, layout3, enum_layout ]
+    [ layout1, layout2, layout3, layout4, layout5, enum_layout ]
   where
     assert_layout tn tys layout =
       let
@@ -75,6 +75,18 @@ layout_tests = sequence_
         , ubxtup [ intPrimTy, intTy, intPrimTy, intTy ] ]
         [ WordSlot, PtrSlot, PtrSlot, WordSlot, WordSlot ]
 
+    layout4 =
+      assert_layout "layout4"
+        [ ubxtup [ floatPrimTy, floatPrimTy ]
+        , ubxtup [ intPrimTy, intPrimTy ] ]
+        [ WordSlot, WordSlot, WordSlot, FloatSlot, FloatSlot ]
+
+    layout5 =
+      assert_layout "layout5"
+        [ ubxtup [ intPrimTy, intPrimTy ]
+        , ubxtup [ floatPrimTy, floatPrimTy ] ]
+        [ WordSlot, WordSlot, WordSlot, FloatSlot, FloatSlot ]
+
     enum_layout =
       assert_layout "enum"
         (replicate 10 (ubxtup []))



More information about the ghc-commits mailing list