From 5a308cf1c6c2e6fab5533209d7c9ea38b1caca44 Mon Sep 17 00:00:00 2001 From: Ilya Enkovich Date: Tue, 1 Dec 2015 11:04:06 +0000 Subject: [PATCH] re PR middle-end/68595 (ice in const_vector_mask_from_tree at expr.c:11455) gcc/ PR middle-end/68595 * tree-vect-stmts.c (vect_init_vector): Cast boolean scalars to a proper value before building a vector. gcc/testsuite/ PR middle-end/68595 * gcc.dg/pr68595.c: New test. From-SVN: r231106 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr68595.c | 13 +++++++++++++ gcc/tree-vect-stmts.c | 20 +++++++++++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr68595.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4dd84c73e74..48256e9ca85 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-01 Ilya Enkovich + + PR middle-end/68595 + * tree-vect-stmts.c (vect_init_vector): Cast boolean + scalars to a proper value before building a vector. + 2015-12-01 Richard Sandiford * genattrtab.c (check_attr_test): Take an attr_desc instead of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e79db4e8a79..07a9e521dfc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-01 Ilya Enkovich + + PR middle-end/68595 + * gcc.dg/pr68595.c: New test. + 2015-12-01 Christian Bruel * gcc.target/arm/ftest-armv6-thumb.c: Remove NEED_ARM_FEATURE_UNALIGNED. diff --git a/gcc/testsuite/gcc.dg/pr68595.c b/gcc/testsuite/gcc.dg/pr68595.c new file mode 100644 index 00000000000..179c6c352d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68595.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b; +char c; +void fn1() { + b = 30; + for (; b <= 32; b++) { + c = -17; + for (; c <= 56; c++) + a -= 0 == (c || b); + } +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 3b078da1320..5bb2289ada0 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -1300,7 +1300,25 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi) { if (!types_compatible_p (TREE_TYPE (type), TREE_TYPE (val))) { - if (CONSTANT_CLASS_P (val)) + /* Scalar boolean value should be transformed into + all zeros or all ones value before building a vector. */ + if (VECTOR_BOOLEAN_TYPE_P (type)) + { + tree true_val = build_zero_cst (TREE_TYPE (type)); + tree false_val = build_all_ones_cst (TREE_TYPE (type)); + + if (CONSTANT_CLASS_P (val)) + val = integer_zerop (val) ? false_val : true_val; + else + { + new_temp = make_ssa_name (TREE_TYPE (type)); + init_stmt = gimple_build_assign (new_temp, COND_EXPR, + val, true_val, false_val); + vect_init_vector_1 (stmt, init_stmt, gsi); + val = new_temp; + } + } + else if (CONSTANT_CLASS_P (val)) val = fold_convert (TREE_TYPE (type), val); else { -- 2.30.2