aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIlya Enkovich <enkovich.gnu@gmail.com>2015-11-06 13:31:51 +0000
committerIlya Enkovich <ienkovich@gcc.gnu.org>2015-11-06 13:31:51 +0000
commitb036c6c53edca64a63460f3976494bd011c5ffb6 (patch)
treedce0c9f8a2a821196685b99d801fc09b84a3d91e /gcc
parent4a4b6c4c277f17b2f33c6c6828a906c028d8a0b6 (diff)
downloadgcc-b036c6c53edca64a63460f3976494bd011c5ffb6.zip
gcc-b036c6c53edca64a63460f3976494bd011c5ffb6.tar.gz
gcc-b036c6c53edca64a63460f3976494bd011c5ffb6.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/vect/pr68145.cc41
-rw-r--r--gcc/tree-vect-stmts.c21
4 files changed, 72 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5e4a1c3..0a83f6f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-06 Ilya Enkovich <enkovich.gnu@gmail.com>
+
+ PR tree-optimization/68145
+ * tree-vect-stmts.c (vectorizable_operation): Fix
+ determination for booleans.
+
2015-11-06 Tom de Vries <tom@codesourcery.com>
* tree-cfg.c (gimple_split_block_before_cond_jump): Split before
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3bf8cf1..749113b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-06 Ilya Enkovich <enkovich.gnu@gmail.com>
+
+ PR tree-optimization/68145
+ * g++.dg/vect/pr68145.cc: New test.
+
2015-11-06 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
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 0000000..51e663a
--- /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 <class T> void operator&&(B p1, T p2) {
+ B a;
+ arrayContTransform(p1, p2, a, A());
+}
+
+template <typename _InputIterator1, typename T, typename _OutputIterator,
+ typename _BinaryOperation>
+void myrtransform(_InputIterator1 p1, _OutputIterator p2, T p3,
+ _BinaryOperation p4) {
+ _InputIterator1 b;
+ for (; b != p1; ++b, ++p2)
+ *p2 = p4(*b, p3);
+}
+
+template <typename L, typename R, typename RES, typename BinaryOperator>
+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 96074fc..51dff9e 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)