re PR tree-optimization/60023 (ICE: verify_gimple failed: dead STMT in EH table with -O3 -fnon-call-exceptions -mavx2)

PR tree-optimization/60023
	* tree-if-conv.c (predicate_mem_writes): Pass true instead of
	false to gsi_replace.
	* tree-vect-stmts.c (vect_finish_stmt_generation): If stmt
	has been in some EH region and vec_stmt could throw, add
	vec_stmt into the same EH region.
	* tree-data-ref.c (get_references_in_stmt): If IFN_MASK_LOAD
	has no lhs, ignore it.
	* internal-fn.c (expand_MASK_LOAD): Likewise.

	* g++.dg/vect/pr60023.cc: New test.

From-SVN: r207464
This commit is contained in:
Jakub Jelinek 2014-02-04 14:08:00 +01:00 committed by Jakub Jelinek
parent eb259c4a32
commit 8e91d222ca
7 changed files with 105 additions and 1 deletions

View File

@ -1,5 +1,15 @@
2014-02-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/60023
* tree-if-conv.c (predicate_mem_writes): Pass true instead of
false to gsi_replace.
* tree-vect-stmts.c (vect_finish_stmt_generation): If stmt
has been in some EH region and vec_stmt could throw, add
vec_stmt into the same EH region.
* tree-data-ref.c (get_references_in_stmt): If IFN_MASK_LOAD
has no lhs, ignore it.
* internal-fn.c (expand_MASK_LOAD): Likewise.
PR ipa/60026
* tree-inline.c (copy_forbidden): Fail for
__attribute__((optimize (0))) functions.

View File

@ -820,6 +820,8 @@ expand_MASK_LOAD (gimple stmt)
maskt = gimple_call_arg (stmt, 2);
lhs = gimple_call_lhs (stmt);
if (lhs == NULL_TREE)
return;
type = TREE_TYPE (lhs);
rhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0),
gimple_call_arg (stmt, 1));

View File

@ -1,5 +1,8 @@
2014-02-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/60023
* g++.dg/vect/pr60023.cc: New test.
PR ipa/60026
* c-c++-common/torture/pr60026.c: New test.

View File

@ -0,0 +1,80 @@
// PR tree-optimization/60023
// { dg-do compile }
// { dg-additional-options "-O3 -std=c++11 -fnon-call-exceptions" }
// { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } }
struct A { A (); ~A (); };
void
f1 (int *p, int *q, int *r) noexcept (true)
{
int i;
for (i = 0; i < 1024; i++)
if (r[i])
p[i] = q[i] + 1;
}
void
f2 (int *p, int *q, int *r)
{
int i;
for (i = 0; i < 1024; i++)
if (r[i])
p[i] = q[i] + 1;
}
void
f3 (int *p, int *q) noexcept (true)
{
int i;
for (i = 0; i < 1024; i++)
p[i] = q[i] + 1;
}
void
f4 (int *p, int *q)
{
int i;
for (i = 0; i < 1024; i++)
p[i] = q[i] + 1;
}
void
f5 (int *p, int *q, int *r) noexcept (true)
{
int i;
A a;
for (i = 0; i < 1024; i++)
if (r[i])
p[i] = q[i] + 1;
}
void
f6 (int *p, int *q, int *r)
{
int i;
A a;
for (i = 0; i < 1024; i++)
if (r[i])
p[i] = q[i] + 1;
}
void
f7 (int *p, int *q) noexcept (true)
{
int i;
A a;
for (i = 0; i < 1024; i++)
p[i] = q[i] + 1;
}
void
f8 (int *p, int *q)
{
int i;
A a;
for (i = 0; i < 1024; i++)
p[i] = q[i] + 1;
}
// { dg-final { cleanup-tree-dump "vect" } }

View File

@ -4401,6 +4401,8 @@ get_references_in_stmt (gimple stmt, vec<data_ref_loc, va_heap> *references)
switch (gimple_call_internal_fn (stmt))
{
case IFN_MASK_LOAD:
if (gimple_call_lhs (stmt) == NULL_TREE)
break;
ref.is_read = true;
case IFN_MASK_STORE:
ref.ref = fold_build2 (MEM_REF,

View File

@ -1723,7 +1723,7 @@ predicate_mem_writes (loop_p loop)
new_stmt
= gimple_build_call_internal (IFN_MASK_STORE, 4, addr, ptr,
mask, rhs);
gsi_replace (&gsi, new_stmt, false);
gsi_replace (&gsi, new_stmt, true);
}
else if (gimple_vdef (stmt))
{

View File

@ -1691,6 +1691,13 @@ vect_finish_stmt_generation (gimple stmt, gimple vec_stmt,
}
gimple_set_location (vec_stmt, gimple_location (stmt));
/* While EH edges will generally prevent vectorization, stmt might
e.g. be in a must-not-throw region. Ensure newly created stmts
that could throw are part of the same region. */
int lp_nr = lookup_stmt_eh_lp (stmt);
if (lp_nr != 0 && stmt_could_throw_p (vec_stmt))
add_stmt_to_eh_lp (vec_stmt, lp_nr);
}
/* Checks if CALL can be vectorized in type VECTYPE. Returns