Patchwork PR53245

login
register
mail settings
Submitter Steven Bosscher
Date May 7, 2012, 2:35 p.m.
Message ID <CABu31nM7xKEhVShEuX9dPyf--QvdWP6PRS4B5O6xnZZULNAk2Q@mail.gmail.com>
Download mbox | patch
Permalink /patch/157334/
State New
Headers show

Comments

Steven Bosscher - May 7, 2012, 2:35 p.m.
Hello,

This patch fixes PR53245.
Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?

Ciao!
Steven


	PR middle-end/53245
	* gimplify.c (preprocess_case_label_vec_for_gimple): If low or high
	is folded to a type boundary value, verify that the resulting case
	label is still a care range.
Richard Guenther - May 7, 2012, 2:36 p.m.
On Mon, May 7, 2012 at 4:35 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> This patch fixes PR53245.
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?

Ok.

Thanks,
Richard.

> Ciao!
> Steven
>
>
>        PR middle-end/53245
>        * gimplify.c (preprocess_case_label_vec_for_gimple): If low or high
>        is folded to a type boundary value, verify that the resulting case
>        label is still a care range.
>
> Index: gimplify.c
> ===================================================================
> --- gimplify.c  (revision 187219)
> +++ gimplify.c  (working copy)
> @@ -1658,6 +1658,10 @@ preprocess_case_label_vec_for_gimple (VEC(tree,hea
>                      && tree_int_cst_compare (high, max_value) > 0)
>                    high = max_value;
>                  high = fold_convert (index_type, high);
> +
> +                 /* We may have folded a case range to a one-value case.  */
> +                 if (tree_int_cst_equal (low, high))
> +                   high = NULL_TREE;
>                }
>            }
H.J. Lu - May 7, 2012, 2:40 p.m.
On Mon, May 7, 2012 at 7:35 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> This patch fixes PR53245.
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?
>
> Ciao!
> Steven
>
>
>        PR middle-end/53245
>        * gimplify.c (preprocess_case_label_vec_for_gimple): If low or high
>        is folded to a type boundary value, verify that the resulting case
>        label is still a care range.
>

Can you add the testcase in

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53245#c1

Thanks.

Patch

Index: gimplify.c
===================================================================
--- gimplify.c	(revision 187219)
+++ gimplify.c	(working copy)
@@ -1658,6 +1658,10 @@  preprocess_case_label_vec_for_gimple (VEC(tree,hea
 		      && tree_int_cst_compare (high, max_value) > 0)
 		    high = max_value;
 		  high = fold_convert (index_type, high);
+
+		  /* We may have folded a case range to a one-value case.  */
+		  if (tree_int_cst_equal (low, high))
+		    high = NULL_TREE;
 		}
 	    }