tree-vect-generic.c (expand_vector_operations_1): Check optab exists before use it.
authorIlya Enkovich <enkovich.gnu@gmail.com>
Fri, 23 Oct 2015 22:41:40 +0000 (22:41 +0000)
committerIlya Enkovich <ienkovich@gcc.gnu.org>
Fri, 23 Oct 2015 22:41:40 +0000 (22:41 +0000)
gcc/

* tree-vect-generic.c (expand_vector_operations_1): Check
optab exists before use it.

gcc/testsuite/

* g++.dg/pr68062.C: New test.

From-SVN: r229275

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr68062.C [new file with mode: 0644]
gcc/tree-vect-generic.c

index 03e2b5c535e9a6c41e69f3ef5ef9040ad9463f2e..e7f94c43a34f86c66e618c5bcf20427df2b2d163 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       * tree-vect-generic.c (expand_vector_operations_1): Check
+       optab exists before use it.
+
 2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
 
        * tree-vect-generic.c (expand_vector_condition): Avoid
index fed7d1018d893a0276460c4344f762853690c15c..4cdccf2179e9eb64bbeb9b01798c50404bff10ac 100644 (file)
@@ -1,3 +1,7 @@
+2015-10-23  Ilya Enkovich  <enkovich.gnu@gmail.com>
+
+       * g++.dg/pr68062.C: New test.
+
 2015-10-23  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/67830
diff --git a/gcc/testsuite/g++.dg/pr68062.C b/gcc/testsuite/g++.dg/pr68062.C
new file mode 100644 (file)
index 0000000..236a488
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-funsigned-char" } */
+
+typedef char __attribute__ ((vector_size (4))) v4qi;
+typedef unsigned char __attribute__ ((vector_size (4))) uv4qi;
+
+v4qi v;
+void ret(char a)
+{
+  v4qi c={a,a,a,a};
+  uv4qi d={a,a,a,a};
+  v = (c!=d);
+}
index d1fc0ba0f5164db65910f7fbcbb422ee1ab78880..d0a4e0f564761a8c33fc87044ce3f86692998838 100644 (file)
@@ -1533,7 +1533,8 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
       && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1)))
     {
       op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar);
-      if (optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
+      if (op != unknown_optab
+         && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing)
        {
          tree slhs = make_ssa_name (TREE_TYPE (srhs1));
          gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2);