tree-optimization/115694 - ICE with complex store rewrite

The following adds a missed check when forwprop attempts to rewrite
a complex store.

	PR tree-optimization/115694
	* tree-ssa-forwprop.cc (pass_forwprop::execute): Check the
	store is complex before rewriting it.

	* g++.dg/torture/pr115694.C: New testcase.
This commit is contained in:
Richard Biener 2024-06-30 13:07:14 +02:00 committed by Richard Biener
parent 55f80c690c
commit 543a5b9da9
2 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,13 @@
// { dg-do compile }
_Complex a;
typedef struct {
double a[2];
} b;
void c(b);
void d()
{
_Complex b1 = a;
b t = __builtin_bit_cast (b, b1);
c(t);
}

View file

@ -3762,6 +3762,8 @@ pass_forwprop::execute (function *fun)
&& gimple_store_p (use_stmt)
&& !gimple_has_volatile_ops (use_stmt)
&& is_gimple_assign (use_stmt)
&& (TREE_CODE (TREE_TYPE (gimple_assign_lhs (use_stmt)))
== COMPLEX_TYPE)
&& (TREE_CODE (gimple_assign_lhs (use_stmt))
!= TARGET_MEM_REF))
{