diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-10-14 15:19:41 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-10-19 10:45:45 -0400 |
commit | 3be48877e204fca8e5d5ab984186e0d20d81f262 (patch) | |
tree | e6950cdf2df8c06454191e3e71150814e8123898 | |
parent | 6d7d91817795d7ee7f45557411368a1738daa488 (diff) | |
download | haskell-3be48877e204fca8e5d5ab984186e0d20d81f262.tar.gz |
Cmm Lint: relax SIMD register assignment check
As noted in #22297, SIMD vector registers can be used
to store different kinds of values, e.g. xmm1 can be used
both to store integer and floating point values.
The Cmm type system doesn't properly account for this, so
we weaken the Cmm register assignment lint check to only
compare widths when comparing a vector type with its
allocated vector register.
-rw-r--r-- | compiler/GHC/Cmm/Lint.hs | 18 | ||||
-rw-r--r-- | testsuite/tests/unboxedsums/all.T | 5 |
2 files changed, 18 insertions, 5 deletions
diff --git a/compiler/GHC/Cmm/Lint.hs b/compiler/GHC/Cmm/Lint.hs index af27e5932a..8ba4f20fa8 100644 --- a/compiler/GHC/Cmm/Lint.hs +++ b/compiler/GHC/Cmm/Lint.hs @@ -174,9 +174,21 @@ lintCmmMiddle node = case node of platform <- getPlatform erep <- lintCmmExpr expr let reg_ty = cmmRegType platform reg - if (erep `cmmEqType_ignoring_ptrhood` reg_ty) - then return () - else cmmLintAssignErr (CmmAssign reg expr) erep reg_ty + unless (compat_regs erep reg_ty) $ + cmmLintAssignErr (CmmAssign reg expr) erep reg_ty + where + compat_regs :: CmmType -> CmmType -> Bool + compat_regs ty1 ty2 + -- As noted in #22297, SIMD vector registers can be used for + -- multiple different purposes, e.g. xmm1 can be used to hold 4 Floats, + -- or 4 Int32s, or 2 Word64s, ... + -- To allow this, we relax the check: we only ensure that the widths + -- match, until we can find a more robust solution. + | isVecType ty1 + , isVecType ty2 + = typeWidth ty1 == typeWidth ty2 + | otherwise + = cmmEqType_ignoring_ptrhood ty1 ty2 CmmStore l r _alignment -> do _ <- lintCmmExpr l diff --git a/testsuite/tests/unboxedsums/all.T b/testsuite/tests/unboxedsums/all.T index 2fb0b9ad60..acfe825080 100644 --- a/testsuite/tests/unboxedsums/all.T +++ b/testsuite/tests/unboxedsums/all.T @@ -36,5 +36,6 @@ test('T20858b', [extra_files(['T20858.hs']) , ghci_script, ['T20858b.script']) test('T20859', normal, compile, ['']) -test('T22187',[only_ways(llvm_ways), expect_broken(22296)],compile,['']) -test('T22187_run',[only_ways(llvm_ways), expect_broken(22296)],compile_and_run,['']) +test('T22187',[only_ways(llvm_ways)],compile,['']) +test('T22187_run',[only_ways(llvm_ways)],compile_and_run,['']) + |