From: Richard Biener Date: Fri, 30 Jun 2017 08:08:33 +0000 (+0000) Subject: re PR tree-optimization/81249 (ICE: error: incompatible types in PHI argument 0) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4812f0b73c076ead7371785770a1736cf4ed1f49;p=gcc.git re PR tree-optimization/81249 (ICE: error: incompatible types in PHI argument 0) 2017-06-30 Richard Biener PR tree-optimization/81249 * tree-vect-loop.c (vect_create_epilog_for_reduction): Convert condition reduction result to original scalar type. * g++.dg/torture/pr81249.C: New testcase. From-SVN: r249831 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ebb0bf32bdc..eab752a5e13 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-06-30 Richard Biener + + PR tree-optimization/81249 + * tree-vect-loop.c (vect_create_epilog_for_reduction): Convert + condition reduction result to original scalar type. + 2017-06-30 Andreas Krebbel * profile-count.h (enum profile_quality): Fix typos and whitespace diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3dad9ec6f6..9b92e447724 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-30 Richard Biener + + PR tree-optimization/81249 + * g++.dg/torture/pr81249.C: New testcase. + 2017-06-29 Paolo Carlini * g++.dg/cpp0x/inh-ctor3.C: Adjust for dg-message vs dg-error. diff --git a/gcc/testsuite/g++.dg/torture/pr81249.C b/gcc/testsuite/g++.dg/torture/pr81249.C new file mode 100644 index 00000000000..7bf617b0421 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr81249.C @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx2 -mprefer-avx128" { target x86_64-*-* i?86-*-* } } */ + +typedef struct rtx_def *rtx; +union rtunion { + rtx rt_rtx; +}; +struct rtx_def { + struct { + rtunion fld[0]; + } u; + rtx elem[]; +} a; +int b, c, d; +rtx e; +int main() { + for (;;) { + d = 0; + for (; d < b; d++) + if (a.elem[d]) + e = a.elem[d]->u.fld[1].rt_rtx; + if (e) + c = 0; + } +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 576a42fc42f..bab0cdd3f51 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -4835,12 +4835,9 @@ vect_create_epilog_for_reduction (vec vect_defs, gimple *stmt, /* Convert the reduced value back to the result type and set as the result. */ - tree data_reduc_cast = build1 (VIEW_CONVERT_EXPR, scalar_type, - data_reduc); - epilog_stmt = gimple_build_assign (new_scalar_dest, data_reduc_cast); - new_temp = make_ssa_name (new_scalar_dest, epilog_stmt); - gimple_assign_set_lhs (epilog_stmt, new_temp); - gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT); + gimple_seq stmts = NULL; + new_temp = gimple_convert (&stmts, scalar_type, data_reduc); + gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT); scalar_results.safe_push (new_temp); } else if (STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) == COND_REDUCTION @@ -4905,6 +4902,11 @@ vect_create_epilog_for_reduction (vec vect_defs, gimple *stmt, val = new_val; } } + /* Convert the reduced value back to the result type and set as the + result. */ + gimple_seq stmts = NULL; + val = gimple_convert (&stmts, scalar_type, val); + gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT); scalar_results.safe_push (val); }