Skip to content

Allow a wrapper with up to more than `-fmax-worker-args` parameters when the number of parameters wouldn't change

Consider

{-# OPTIONS_GHC -fforce-recomp -O2 -fmax-worker-args=1 #-}
module Lib where

foo :: (Int, Int) -> Int -> Int
foo (x, y) z = x+z
{-# NOINLINE foo #-}

Take note of -fmax-worker-args=1. We could WW to

$wfoo :: Int# -> Int# -> Int#
$wfoo x z = x +# z

foo :: (Int, Int) -> Int -> Int
foo (I# x, _) (I# z) = I# ($wfoo x z)

But currently, we don't, because the new arity 2 exceeds -fmax-worker-args=1. But actually, the new arity is no larger than the old arity! Hence we should allow WW to do its work here.

(Note that both NOINLINE for such a small function and -fmax-worker-args=1 are unrealistic, but it's a minimal program)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information