id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
932	Improve inlining	simonpj	simonpj	"Currently the contruct
{{{
  case (x# ># 0#) of ...
}}}
attracts no argument discount for x#, which is silly.

The comment in CoreUnfold says:
{{{
	  PrimOpId op  -> primOpSize op (valArgCount args)
			  -- foldr addSize (primOpSize op) (map arg_discount args)
			  -- At one time I tried giving an arg-discount if a primop 
			  -- is applied to one of the function's arguments, but it's
			  -- not good.  At the moment, any unlifted-type arg gets a
			  -- 'True' for 'yes I'm evald', so we collect the discount even
			  -- if we know nothing about it.  And just having it in a primop
			  -- doesn't help at all if we don't know something more.
}}}
But the right thing to do seems to be to fix interestingArg in SimplUtils so that it only thinks a primitive-typed thing is interesting if it knows its value (or some structure).

Here's the program that triggered this thought:
{{{
import GHC.Word
import GHC.Base
import GHC.Prim

a `shiftRLT` b | b >=# 32# = int2Word# 0#
                | otherwise = a `uncheckedShiftRL#` b

(W32# x#) `shift` (I# i#) =
{- we do an actual case analysis on i# to try to give us a discount -}
   case i# of
    {- For some bizzare reason removing the `shiftRLT` 0# makes the
       inlining fail again -}
    0# -> W32# (x# `shiftRLT` 0#)
    _ -> 
	 if i# >=# 0# then W32# (narrow32Word# (x# `shiftL#` i#))
         else W32# (x# `shiftRLT` negateInt# i#)

x `shiftR` y = x `shift` (-y)

shift7 x = x `shiftR` 7
}}}
roconnor@theorem.ca initiated the thread"	task	new	normal	_|_	Compiler	6.4.2			samb simonpj	Unknown/Multiple	Unknown/Multiple		Unknown	N/A			
