It might be they are not required.
In example like
{-# OPTIONS_GHC -ddump-simpl -dsuppress-all #-}
import System.Environment
import Data.Word
main :: IO ()
main = do
[x',y'] <- getArgs
let x, y :: Word
x = read x'
y = read y'
print (not (x == y))
GHC is smart enough to just swap the branches, relevant optimized
core looks like
case x_a4Tc of { W# x2_a3Wb ->
case x1_X4Ua of { W# y_a3Wf ->
case eqWord# x2_a3Wb y_a3Wf of {
__DEFAULT -> $fShowBool2;
1# -> $fShowBool4
}
}
};
where `$fShowBool*` are (probably, I haven't checked) printing
True or False.
I.e. expressions which are "case (not x) of True -> ..., False
-> ..." optimize well,
early enough. (IIRC that's the example used for case-of-case
optimization).
- Oleg
Am Mi., 20. Okt. 2021 um 18:51 Uhr schrieb Oleg Grenrus <oleg.grenrus@iki.fi>:
[...] Also, we coudl add builtin rewrite rules, rewriting not (eqInt8 x y)
to neInt8 x y if some benchmarks show that it would be beneficial.
Hopefully such peephole optimizations are done much more generally further down the compilation pipeline, otherwise we will have more serious performance problems than the removal of (/=) from Eq. ;-)