Optimization for binary masks
GHC doesn't optimize binary masks as in this example:
foo :: Int -> Int foo x = case x .&. 0x3 of 0 -> 0 1 -> 1 2 -> 2 3 -> 3 4 -> 4 -- unreachable branch but not removed _ -> undefined -- required for the PM checker but unreachable too
- In Core: detect ranges in these cases and remove unreachable branches. To fix this example, we should just have to enhance
GHC.Core.Opt.ConstantFold.caseRulesto detect (potentially nested) applications of
andprimops with a constant.
- Fix Pattern-Match checker to not require a DEFAULT alternative and to not insert a
patErrorif it is missing.