From b036c6c53edca64a63460f3976494bd011c5ffb6 Mon Sep 17 00:00:00 2001 From: Ilya Enkovich Date: Fri, 6 Nov 2015 13:31:51 +0000 Subject: [PATCH] re PR tree-optimization/68145 (ICE: in vectorizable_store, at tree-vect-stmts.c:5684) gcc/ PR tree-optimization/68145 * tree-vect-stmts.c (vectorizable_operation): Fix determination for booleans. gcc/testsuite/ PR tree-optimization/68145 * g++.dg/vect/pr68145.cc: New test. From-SVN: r229848 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/vect/pr68145.cc | 41 ++++++++++++++++++++++++++++ gcc/tree-vect-stmts.c | 21 +++++++++++++- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/vect/pr68145.cc diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e4a1c333ef..0a83f6fbe97 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-06 Ilya Enkovich + + PR tree-optimization/68145 + * tree-vect-stmts.c (vectorizable_operation): Fix + determination for booleans. + 2015-11-06 Tom de Vries * tree-cfg.c (gimple_split_block_before_cond_jump): Split before diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3bf8cf1bca0..749113ba8b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-06 Ilya Enkovich + + PR tree-optimization/68145 + * g++.dg/vect/pr68145.cc: New test. + 2015-11-06 Kyrylo Tkachov PR target/68088 diff --git a/gcc/testsuite/g++.dg/vect/pr68145.cc b/gcc/testsuite/g++.dg/vect/pr68145.cc new file mode 100644 index 00000000000..51e663ae636 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr68145.cc @@ -0,0 +1,41 @@ +/* { dg-do compile } */ + +struct A { + bool operator()(int p1, int p2) { return p1 && p2; } +}; +class B { +public: + bool *cbegin(); + bool *cend(); +}; +template void operator&&(B p1, T p2) { + B a; + arrayContTransform(p1, p2, a, A()); +} + +template +void myrtransform(_InputIterator1 p1, _OutputIterator p2, T p3, + _BinaryOperation p4) { + _InputIterator1 b; + for (; b != p1; ++b, ++p2) + *p2 = p4(*b, p3); +} + +template +void arrayContTransform(L p1, R p2, RES p3, BinaryOperator p4) { + myrtransform(p1.cend(), p3.cbegin(), p2, p4); +} + +class C { +public: + B getArrayBool(); +}; +class D { + B getArrayBool(const int &); + C lnode_p; +}; +bool c; +B D::getArrayBool(const int &) { lnode_p.getArrayBool() && c; } + +// { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { i?86-*-* x86_64-*-* } } } } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 96074fcaa2c..51dff9eb19e 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -4703,7 +4703,26 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi, /* If op0 is an external or constant def use a vector type with the same size as the output vector type. */ if (!vectype) - vectype = get_same_sized_vectype (TREE_TYPE (op0), vectype_out); + { + /* For boolean type we cannot determine vectype by + invariant value (don't know whether it is a vector + of booleans or vector of integers). We use output + vectype because operations on boolean don't change + type. */ + if (TREE_CODE (TREE_TYPE (op0)) == BOOLEAN_TYPE) + { + if (TREE_CODE (TREE_TYPE (scalar_dest)) != BOOLEAN_TYPE) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not supported operation on bool value.\n"); + return false; + } + vectype = vectype_out; + } + else + vectype = get_same_sized_vectype (TREE_TYPE (op0), vectype_out); + } if (vec_stmt) gcc_assert (vectype); if (!vectype) -- 2.30.2