Hi, the patch below makes SRA produce intere type replacements when it currently produces enumeration type ones because this then may cause VRP to assume wrong bounds (PR 49911).
I do not know how to create a testcase for the PR this should solve because I could not reproduce it on yesterday's trunk checkout. The patch is against trunk, where it successfully passes bootstrap and testing on x86_64-linux, but applies well also to 4.6 and 4.5 branches and there has been a request to commit them there as well so I'd like to do so (after testing it on them which I have not done yet). OK? Thanks, Martin 2011-09-05 Martin Jambor <[email protected]> PR tree-optimization/49911 * tree-sra.c (analyze_access_subtree): Change type of to-be-replaced enumerations to the corresponding plain integer type. Index: src/gcc/tree-sra.c =================================================================== --- src.orig/gcc/tree-sra.c +++ src/gcc/tree-sra.c @@ -2075,13 +2075,25 @@ analyze_access_subtree (struct access *r || ((root->grp_scalar_read || root->grp_assignment_read) && (root->grp_scalar_write || root->grp_assignment_write)))) { + bool new_integer_type; + if (TREE_CODE (root->type) == ENUMERAL_TYPE) + { + tree rt = root->type; + root->type = build_nonstandard_integer_type (TYPE_PRECISION (rt), + TYPE_UNSIGNED (rt)); + new_integer_type = true; + } + else + new_integer_type = false; + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Marking "); print_generic_expr (dump_file, root->base, 0); - fprintf (dump_file, " offset: %u, size: %u: ", + fprintf (dump_file, " offset: %u, size: %u ", (unsigned) root->offset, (unsigned) root->size); - fprintf (dump_file, " to be replaced.\n"); + fprintf (dump_file, " to be replaced%s.\n", + new_integer_type ? " with an integer": ""); } root->grp_to_be_replaced = 1;
