diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2016-08-09 22:30:56 +0000 |
---|---|---|
committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2016-08-09 22:30:56 +0000 |
commit | e79bb2c10d66ec8f0c037e66c7d0a22aa887fdc1 (patch) | |
tree | 60063796e57d702cb468e24f34a424e52909266a | |
parent | dd23a4c067323cdc948a66f1c19fbd6b94374759 (diff) | |
download | haskell-e79bb2c10d66ec8f0c037e66c7d0a22aa887fdc1.tar.gz |
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.
-rw-r--r-- | compiler/simplStg/RepType.hs | 4 | ||||
-rw-r--r-- | 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 7e42a866b0..ca8438eec1 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 5c0b929f78..399e074991 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 [])) |