summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-10-14 15:19:41 +0200
committerZubin Duggal <zubin.duggal@gmail.com>2022-11-03 15:12:38 +0530
commit9d469bff9626fb65a53978008324b0306e9af3fb (patch)
tree188f55a265761f04a803431761a33cf1f9c90bc6
parent1fabaae44d3045db43d1b9227950af16306d5080 (diff)
downloadhaskell-9d469bff9626fb65a53978008324b0306e9af3fb.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.hs18
-rw-r--r--testsuite/tests/unboxedsums/all.T6
2 files changed, 19 insertions, 5 deletions
diff --git a/compiler/GHC/Cmm/Lint.hs b/compiler/GHC/Cmm/Lint.hs
index 3b7295f9f1..8084f4fe7c 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 b86e65a4b0..a34c52f656 100644
--- a/testsuite/tests/unboxedsums/all.T
+++ b/testsuite/tests/unboxedsums/all.T
@@ -27,5 +27,7 @@ test('T12711', only_ways(['ghci']), ghci_script, ['T12711.script'])
test('UbxSumLevPoly', normal, compile, ['-Wno-overlapping-patterns'])
test('T14051', normal, multi_compile, ['T14051.hs', [('T14051a.hs', '')], '-O2 -v0'])
test('T19645', normal, compile_and_run, [''])
-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,[''])
+