From 52e5b3fd8ef1d1b3ff86e26bd0aa7266bd9767fd Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 23 Sep 2020 10:42:48 +0200 Subject: [PATCH] tree-optimization/97173 - extend assert in vectorizable_live_operation The condition we're expecting to eventually run into isn't fully captured by checking for CTORs, instead we can also run into the CTOR element conversion. 2020-09-23 Richard Biener PR tree-optimization/97173 * tree-vect-loop.c (vectorizable_live_operation): Extend assert to also conver element conversions. * gcc.dg/vect/pr97173.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr97173.c | 19 +++++++++++++++++++ gcc/tree-vect-loop.c | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr97173.c diff --git a/gcc/testsuite/gcc.dg/vect/pr97173.c b/gcc/testsuite/gcc.dg/vect/pr97173.c new file mode 100644 index 00000000000..fd4a8893164 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr97173.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +typedef struct { + char *track; + char *clocks; + char *fm; + char *weak; +} disk_t; + +disk_t disk_update_tlens_d; +int disk_update_tlens_d_0; + +void disk_update_tlens() { + disk_update_tlens_d.track = disk_update_tlens_d.clocks = + disk_update_tlens_d.track + disk_update_tlens_d_0; + disk_update_tlens_d.fm = disk_update_tlens_d.clocks + disk_update_tlens_d_0; + disk_update_tlens_d.weak = disk_update_tlens_d.fm; + disk_update_tlens_d.track[2] = 5; +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index b1a6e1508c7..46d126c54ba 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -8345,8 +8345,10 @@ vectorizable_live_operation (vec_info *vinfo, if (gimple_code (use_stmt) != GIMPLE_PHI && !vect_stmt_dominates_stmt_p (gsi_stmt (*gsi), use_stmt)) { - gcc_assert (is_gimple_assign (use_stmt) - && gimple_assign_rhs_code (use_stmt) == CONSTRUCTOR); + enum tree_code code = gimple_assign_rhs_code (use_stmt); + gcc_assert (code == CONSTRUCTOR + || code == VIEW_CONVERT_EXPR + || CONVERT_EXPR_CODE_P (code)); if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "Using original scalar computation for " -- 2.30.2