GHC.Float.roundingMode# is recursive
... and that may make it more difficult to optimise. At least we'll never inline it.
But it appears the recursiveness is for no apparent reason:
-- Assumption: Integer and Int# are strictly positive, Int# is less
-- than logBase 2 of Integer, otherwise havoc ensues.
-- ...
roundingMode# :: Integer -> Int# -> Int#
roundingMode# (IS i#) t = ...
roundingMode# (IN bn) t = roundingMode# (IP bn) t -- dummy
roundingMode# (IP bn) t = ...
Given the assumption, we could just as well panic, I think. Let's do that. If that isn't possible and we really call roundingMode#
on negative numbers, we should extract a local helper function instead and do the IN -> IP conversion before calling that helper.
Pinging @hsyl20, hoping he knows whether or not panicking here would work.