Cse rewrite

A rewrite of common-subexpression-elimination. The old version was pretty flaky.
Is there a missing early out if result is not Equal? It seems like this function might obliterate a previous non-Equal result. The other 'compare_...' functions seem to avoid this.