diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-02-20 16:48:16 +0100 |
---|---|---|
committer | Sebastian Graf <sebastian.graf@kit.edu> | 2020-02-26 13:35:54 +0100 |
commit | 054e7ac57418c55f1004cf432cb3a5485464fd4b (patch) | |
tree | f03d566d38a9a52e479f5b2d8a22fc4bc8390089 /compiler/GHC/CmmToLlvm/CodeGen.hs | |
parent | 9d09411122b9b534b96e988b6d3f6d7eb04b8f66 (diff) | |
download | haskell-wip/pmcheck-ldi.tar.gz |
PmCheck: Implement Long-distance information with Covered setswip/pmcheck-ldi
Consider
```hs
data T = A | B | C
f :: T -> Int
f A = 1
f x = case x of
A -> 2
B -> 3
C -> 4
```
Clearly, the RHS returning 2 is redundant. But we don't currently see
that, because our approximation to the covered set of the inner case
expression just picks up the positive information from surrounding
pattern matches. It lacks the context sensivity that `x` can't be `A`
anymore!
Therefore, we adopt the conceptually and practically superior approach
of reusing the covered set of a particular GRHS from an outer pattern
match. In this case, we begin checking the `case` expression with the
covered set of `f`s second clause, which encodes the information that
`x` can't be `A` anymore. After this MR, we will successfully warn about
the RHS returning 2 being redundant.
Perhaps surprisingly, this was a great simplification to the code of
both the coverage checker and the desugarer.
Found a redundant case alternative in `unix` submodule, so we have to
bump it with a fix.
Metric Decrease:
T12227
Diffstat (limited to 'compiler/GHC/CmmToLlvm/CodeGen.hs')
-rw-r--r-- | compiler/GHC/CmmToLlvm/CodeGen.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/GHC/CmmToLlvm/CodeGen.hs b/compiler/GHC/CmmToLlvm/CodeGen.hs index 62ebeb9ba7..e01c6fe886 100644 --- a/compiler/GHC/CmmToLlvm/CodeGen.hs +++ b/compiler/GHC/CmmToLlvm/CodeGen.hs @@ -1482,17 +1482,20 @@ genMachOp_slow opt op [x, y] = case op of MO_FF_Conv _ _ -> panicOp MO_V_Insert {} -> panicOp - MO_V_Extract {} -> panicOp MO_VS_Neg {} -> panicOp MO_VF_Insert {} -> panicOp - MO_VF_Extract {} -> panicOp MO_VF_Neg {} -> panicOp MO_AlignmentCheck {} -> panicOp +#if __GLASGOW_HASKELL__ < 811 + MO_VF_Extract {} -> panicOp + MO_V_Extract {} -> panicOp +#endif + where binLlvmOp ty binOp = runExprData $ do vx <- exprToVarW x |