From bfccadc9249b4c55b748ddefbec8c8344f6deac2 Mon Sep 17 00:00:00 2001 From: Ilya Enkovich Date: Fri, 23 Oct 2015 22:41:40 +0000 Subject: [PATCH] tree-vect-generic.c (expand_vector_operations_1): Check optab exists before use it. 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 | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/pr68062.C | 13 +++++++++++++ gcc/tree-vect-generic.c | 3 ++- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/pr68062.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 03e2b5c535e..e7f94c43a34 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-10-23 Ilya Enkovich + + * tree-vect-generic.c (expand_vector_operations_1): Check + optab exists before use it. + 2015-10-23 Ilya Enkovich * tree-vect-generic.c (expand_vector_condition): Avoid diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fed7d1018d8..4cdccf2179e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-10-23 Ilya Enkovich + + * g++.dg/pr68062.C: New test. + 2015-10-23 Jeff Law PR tree-optimization/67830 diff --git a/gcc/testsuite/g++.dg/pr68062.C b/gcc/testsuite/g++.dg/pr68062.C new file mode 100644 index 00000000000..236a4885ac9 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr68062.C @@ -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); +} diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index d1fc0ba0f51..d0a4e0f5647 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -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); -- 2.30.2