Also might want to check these links.
http://mathematica.stackexchange.com/questions/25132/common-subexpression-from-two-expressions
http://stackoverflow.com/questions/4202845/mathematica-using-simplify-to-do-common-sub-expression-elimination-and-reductio
http://mathematica.stackexchange.com/questions/8787/find-subexpression-to-minimize-leafcount-after-replacment-with-temporary-variabl/8792#8792
You might look at this Common subexpression eliminator which seems close to what you are looking for.