diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-10-14 15:19:41 +0200 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2022-12-13 09:30:48 +0000 |
commit | 2e778abc159b4ec060c82e00cc75f04d39a3a933 (patch) | |
tree | 4b59da76df8090e11206fab4e3af1602d3983cfe | |
parent | 19d7a5fc8f5c9f421987935bc4e9bc9f79f3c445 (diff) | |
download | haskell-2e778abc159b4ec060c82e00cc75f04d39a3a933.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.
(cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262)
-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 e76be551f9..ad58629c44 100644 --- a/compiler/GHC/Cmm/Lint.hs +++ b/compiler/GHC/Cmm/Lint.hs @@ -170,9 +170,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 6e77687ce4..a65a1a09c9 100644 --- a/testsuite/tests/unboxedsums/all.T +++ b/testsuite/tests/unboxedsums/all.T @@ -46,5 +46,6 @@ test('ManyUbxSums', [('ManyUbxSums_Addr.hs','')] , '-v0 -dstg-lint -dcmm-lint']) -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,['']) + |