diff options
author | Richard Biener <rguenther@suse.de> | 2020-12-10 11:12:53 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-12-10 12:36:19 +0100 |
commit | 76c09f2af9d8ab9c760d860626f069d12d86f0a9 (patch) | |
tree | 8d65a235ca07924d52b8d5e7953aa44dad9c07f2 | |
parent | f2a5e5f3e6d770d16ad3c48c753a952a40c09c16 (diff) | |
download | gcc-76c09f2af9d8ab9c760d860626f069d12d86f0a9.zip gcc-76c09f2af9d8ab9c760d860626f069d12d86f0a9.tar.gz gcc-76c09f2af9d8ab9c760d860626f069d12d86f0a9.tar.bz2 |
tree-optimization/98211 - fix bogus vectorization of conversion
Pattern recog incompletely handles some bool cases but we shouldn't
miscompile as a result but not vectorize. Unfortunately
vectorizable_assignment lets invalid conversions (that
vectorizable_conversion rejects) slip through. The following
rectifies that.
2020-12-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/98211
* tree-vect-stmts.c (vectorizable_assignment): Disallow
invalid conversions to bool vector types.
* gcc.dg/pr98211.c: New testcase.
-rw-r--r-- | gcc/testsuite/gcc.dg/pr98211.c | 51 | ||||
-rw-r--r-- | gcc/tree-vect-stmts.c | 11 |
2 files changed, 62 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr98211.c b/gcc/testsuite/gcc.dg/pr98211.c new file mode 100644 index 0000000..cea371d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98211.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu90 -O3 -fgimple" } */ + +int test_var_3; +short arr_20[16]; +void __GIMPLE (ssa,startwith("slp")) +test (int var_1, short int a, short int b, short int c, short int d) +{ + _Bool tem2; + _Bool tem; + unsigned int i_5; + int _24; + _Bool _28; + short int _30; + short int _32; + + __BB(2): + _24 = test_var_3; + tem_25 = _24 != 0; + tem2_26 = var_1_11(D) != 0; + _28 = tem_25 | tem2_26; + _30 = _28 != _Literal (_Bool) 0 ? a_16(D) : b_15(D); + arr_20[0u] = _30; + _32 = _28 != _Literal (_Bool) 0 ? c_19(D) : d_18(D); + arr_20[8u] = _32; + arr_20[1u] = _30; + arr_20[9u] = _32; + arr_20[2u] = _30; + arr_20[10u] = _32; + arr_20[3u] = _30; + arr_20[11u] = _32; + arr_20[4u] = _30; + arr_20[12u] = _32; + arr_20[5u] = _30; + arr_20[13u] = _32; + arr_20[6u] = _30; + arr_20[14u] = _32; + arr_20[7u] = _30; + arr_20[15u] = _32; + return; +} + + +int +main() +{ + test (1, 0x88, 0x77, 0x77, 0x88); + if (arr_20[0] != 0x88) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index a4980a9..d3ab8aa 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -5123,6 +5123,17 @@ vectorizable_assignment (vec_info *vinfo, GET_MODE_SIZE (TYPE_MODE (vectype_in))))) return false; + if (VECTOR_BOOLEAN_TYPE_P (vectype) + && !VECTOR_BOOLEAN_TYPE_P (vectype_in)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "can't convert between boolean and non " + "boolean vectors %T\n", TREE_TYPE (op)); + + return false; + } + /* We do not handle bit-precision changes. */ if ((CONVERT_EXPR_CODE_P (code) || code == VIEW_CONVERT_EXPR) |