aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-20 08:40:08 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-20 08:40:08 +0000
commit208a4a269e5c2f5da3e50c8404bf044aa611276b (patch)
treebc0a432becd2bf2099d0dd3c241b9678f4c01a3a
parent973a5f198acf0c9a8fbbf86eaf487abee9f857ba (diff)
PR tree-optimization/56635
* tree-ssa-phiopt.c (cond_if_else_store_replacement_1): Give up if lhs of then_assign and else_assign don't have compatible types. * g++.dg/torture/pr56635.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@196808 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr56635.C17
-rw-r--r--gcc/tree-ssa-phiopt.c6
4 files changed, 32 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0e23a632701..2a646b26a4e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56635
+ * tree-ssa-phiopt.c (cond_if_else_store_replacement_1): Give up
+ if lhs of then_assign and else_assign don't have compatible types.
+
2013-03-17 Jakub Jelinek <jakub@redhat.com>
PR target/56640
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index caf8f6d1e2f..3ab5575f631 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56635
+ * g++.dg/torture/pr56635.C: New test.
+
2013-03-15 Tobias Burnus <burnus@net-b.de>
PR fortran/56615
diff --git a/gcc/testsuite/g++.dg/torture/pr56635.C b/gcc/testsuite/g++.dg/torture/pr56635.C
new file mode 100644
index 00000000000..53d6bb96ad5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr56635.C
@@ -0,0 +1,17 @@
+// PR tree-optimization/56635
+// { dg-do compile }
+
+struct A { _Complex double a; };
+
+void
+foo (A **x, A **y)
+{
+ A r;
+ if (__real__ x[0]->a)
+ {
+ r.a = y[0]->a / x[0]->a;
+ **x = r;
+ }
+ else
+ **x = **y;
+}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 300016f7a0b..973a3617fe1 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1528,7 +1528,7 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb,
basic_block join_bb, gimple then_assign,
gimple else_assign)
{
- tree lhs_base, lhs, then_rhs, else_rhs, name;
+ tree lhs_base, lhs, else_lhs, then_rhs, else_rhs, name;
source_location then_locus, else_locus;
gimple_stmt_iterator gsi;
gimple newphi, new_stmt;
@@ -1544,8 +1544,10 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb,
return false;
lhs = gimple_assign_lhs (then_assign);
+ else_lhs = gimple_assign_lhs (else_assign);
if (!is_gimple_reg_type (TREE_TYPE (lhs))
- || !operand_equal_p (lhs, gimple_assign_lhs (else_assign), 0))
+ || !operand_equal_p (lhs, else_lhs, 0)
+ || !types_compatible_p (TREE_TYPE (lhs), TREE_TYPE (else_lhs)))
return false;
lhs_base = get_base_address (lhs);