Yet Another Hoopl Question

Jan Stolarek jan.stolarek at
Tue Aug 13 15:46:53 CEST 2013

> The next question is "well how do I do this then?". I'm not quite sure, 
> maybe you need to use a deterministic name supply monad.

So why are Hoopl's rewrite functions specialized to UniqSM monad? My understanding so far was that this is precisely because we need access to Uniq supply to generate new labels and registers during rewriting. I'm guessing that nobody intended that these newly generated things will be added as facts?

> Forgive me for asking the classic question: "What are you really trying to do?"

I'm doing copy (constant) propagation and one of my intentions is to minimize traffic to/from the stack when possible. Since I cannot propagate complicated_expr, I rewrite a store to a stack location with

  newReg1 = complicated_expr
  I32[(old + 4)] = newReg1

By recording second assignment as a fact it is now possible to replace references to I32[(old + 4)] with references to newReg1, which will effectively make "I32[(old + 4)] = newReg1" assignment dead. So now information will be kept in registers instead of the stack. Of course it is still possible that there will be not enough registers and we'll have to spill some things to the stack.


More information about the ghc-devs mailing list