On Thu, Jul 7, 2011 at 12:41 PM, Andrew Stubbs <andrew.stu...@gmail.com> wrote: > On 07/07/11 11:04, Richard Guenther wrote: >> >> Both types are equal, so please share the temporary variable you >> create >> >> + rhs1 = build_and_insert_cast (gsi, gimple_location (stmt), >> + create_tmp_var (type1, NULL), >> rhs1, type1); >> + rhs2 = build_and_insert_cast (gsi, gimple_location (stmt), >> + create_tmp_var (type2, NULL), >> rhs2, type2); >> >> here (CSE create_tmp_var). > > I'm sorry, I don't understand this? > > This takes code like this: > > r1 = a; > r2 = b; > result = r1 + r2; > > And transforms it to this: > > r1 = a; > r2 = b; > t1 = (type1) r1; > t2 = (type2) r2; > result = t1 + t2; > > Yes, type1 == type2, but r1 != r2, so t1 != t2. > > I don't see where the common expression is here? But then, I am something of > a newbie to tree optimizations.
create_tmp_var creates a var-decl, build_and_insert_casts builds an SSA name from it. You can build multiple SSA names from a single VAR_DECL, so no need to waste two VAR_DECLs for temporaries of the same type. Richard. > Andrew >