Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
Directly sets result, should this function check result and return for non-Equal before entering?