Idea: use top-level constructors as SRTs
module Lib where
import Debug.Trace
data T = T Integer Integer
i1, i2 :: Integer
i1 = trace "evaluating i1" 123123
i2 = trace "evaluating i2" 840780
{-# NOINLINE i1 #-}
{-# NOINLINE i2 #-}
t = T i1 i2
x = i1 + i2
In this program x
has CAFFY references to plusInteger
(not sure why this is CAFFY?), i1
, and i2
. So the SRT is {plusInteger, i1, i2}
.
However in the same module we already have a constructor with references to i1
and i2
: t
. Similar to how we would reuse another SRT with {i1, i2}
in the SRT for x
, I think we should be using this constructor as an SRT and generating {t, plusInteger}
as x
's SRT.
An SRT is just a constructor. So we should be treating an SRT with {i1, i2}
and a constructor with references {i1,i2}
the same way. There's really no difference in generated code.
cc @simonmar