On Thu, May 5, 2016 at 5:08 PM, Eric Botcazou <ebotca...@adacore.com> wrote: > Hi, > > gimple_can_coalesce_p is rather picky about the conditions under which SSA > names can be coalesced. In particular, when it comes to the type, it's: > > /* Now check the types. If the types are the same, then we should > try to coalesce V1 and V2. */ > tree t1 = TREE_TYPE (name1); > tree t2 = TREE_TYPE (name2); > if (t1 == t2) > > or > > /* If the types are not the same, check for a canonical type match. This > (for example) allows coalescing when the types are fundamentally the > same, but just have different names. > > Note pointer types with different address spaces may have the same > canonical type. Those are rejected for coalescing by the > types_compatible_p check. */ > if (TYPE_CANONICAL (t1) > && TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2) > && types_compatible_p (t1, t2)) > goto check_modes; > > The test on TYPE_CANONICAL looks overkill to me. It's needed in the non- > optimized case (-fno-tree-coalesce-vars) as compute_samebase_partition_bases > uses TYPE_CANONICAL to discriminate partitions, but it's not needed in the > optimized case as compute_optimized_partition_bases uses the full information. > For example, in Ada it prevents subtypes from being coalesced with types and > in C++ it prevents different pointer types from being coalesced. Hence the > attached patch, which lifts the restriction in the optimized case. > > Tested on x86_64-suse-linux, OK for the mainline?
Ok. Richard. > > 2016-05-05 Eric Botcazou <ebotca...@adacore.com> > > * tree-ssa-coalesce.c (gimple_can_coalesce_p): In the optimized case, > allow coalescing if the types are compatible. > > -- > Eric Botcazou