- /* Don't coalesce if the two variables aren't type compatible. */
- if (!types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
+ /* Don't coalesce if the new chosen root variable would be read-only.
+ If both ign1 && ign2, then the root var of the larger partition
+ wins, so reject in that case if any of the root vars is TREE_READONLY.
+ Otherwise reject only if the root var, on which replace_ssa_name_symbol
+ will be called below, is readonly. */
+ if ((TREE_READONLY (root1) && ign2) || (TREE_READONLY (root2) && ign1))
+ {
+ if (debug)
+ fprintf (debug, " : Readonly variable. No coalesce.\n");
+ return false;
+ }
+
+ /* Don't coalesce if the two variables aren't type compatible . */
+ if (!types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2))
+ /* There is a disconnect between the middle-end type-system and
+ VRP, avoid coalescing enum types with different bounds. */
+ || ((TREE_CODE (TREE_TYPE (root1)) == ENUMERAL_TYPE
+ || TREE_CODE (TREE_TYPE (root2)) == ENUMERAL_TYPE)
+ && TREE_TYPE (root1) != TREE_TYPE (root2)))