From d362ac6c6d5a9419d9b7a0db84155a065e113434 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 25 Sep 2017 11:40:23 +0000 Subject: [PATCH] re PR tree-optimization/82285 (Optimizing error when using enumeration) 2017-09-25 Richard Biener PR tree-optimization/82285 * tree-vect-patterns.c (vect_recog_bool_pattern): Also handle enumeral types. * gcc.dg/torture/pr82285.c: New testcase. From-SVN: r253146 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr82285.c | 16 ++++++++++++++++ gcc/tree-vect-patterns.c | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr82285.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8b379b751cb..f618113eb6f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-09-25 Richard Biener + + PR tree-optimization/82285 + * tree-vect-patterns.c (vect_recog_bool_pattern): Also handle + enumeral types. + 2017-09-25 Tom de Vries PR target/80035 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a25a145829..333e2c8f62c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-25 Richard Biener + + PR tree-optimization/82285 + * gcc.dg/torture/pr82285.c: New testcase. + 2017-09-25 Justin Squirek * gnat.dg/entry_family.adb: New testcase diff --git a/gcc/testsuite/gcc.dg/torture/pr82285.c b/gcc/testsuite/gcc.dg/torture/pr82285.c new file mode 100644 index 00000000000..6edc75070b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr82285.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +enum tst { first = 0, second = 1 }; + +int +main () +{ + enum tst data[16]; + + for (unsigned i = 0; i < 16; i++) + data[i] = (i < 5 ? second : first); + + if (data[2] != second) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index cdad26112e4..ed0879eddf9 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -3643,7 +3643,7 @@ vect_recog_bool_pattern (vec *stmts, tree *type_in, rhs_code = gimple_assign_rhs_code (last_stmt); if (CONVERT_EXPR_CODE_P (rhs_code)) { - if (TREE_CODE (TREE_TYPE (lhs)) != INTEGER_TYPE + if (! INTEGRAL_TYPE_P (TREE_TYPE (lhs)) || TYPE_PRECISION (TREE_TYPE (lhs)) == 1) return NULL; vectype = get_vectype_for_scalar_type (TREE_TYPE (lhs)); -- 2.30.2