Hi,

You will always have random OUTPUT state at power on ...

So, just Write

GPIO = % xxxxxxxx

BEFORE setting your Tris Register ...

and do not forget your inputs will be floating for some ms at startup ( hardware pull up or down resistors to place, i.e. when driving Mosfets ...)

Alain

EDIT : +1 with Sinoteq, then !!!