Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
I'm not necessarily recommending a change here, but I think that either this should be dead code (is_const should have returned true) or maybe is_const should return true for StringImms.