This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR82902
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Nov 2017 13:21:07 +0100 (CET)
- Subject: [PATCH] Fix PR82902
- Authentication-results: sourceware.org; auth=none
The following fixes PR82902.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2017-11-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/82902
* tree-ssa-phiprop.c (propagate_with_phi): Test proper type.
* g++.dg/torture/pr82902.C: New testcase.
Index: gcc/tree-ssa-phiprop.c
===================================================================
--- gcc/tree-ssa-phiprop.c (revision 254560)
+++ gcc/tree-ssa-phiprop.c (working copy)
@@ -354,7 +354,7 @@ propagate_with_phi (basic_block bb, gphi
/* Found a proper dereference with an aggregate copy. Just
insert aggregate copies on the edges instead. */
- if (!is_gimple_reg_type (TREE_TYPE (TREE_TYPE (ptr))))
+ if (!is_gimple_reg_type (TREE_TYPE (gimple_assign_lhs (use_stmt))))
{
if (!gimple_vdef (use_stmt))
goto next;
Index: gcc/testsuite/g++.dg/torture/pr82902.C
===================================================================
--- gcc/testsuite/g++.dg/torture/pr82902.C (nonexistent)
+++ gcc/testsuite/g++.dg/torture/pr82902.C (working copy)
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+typedef struct el_t {
+ el_t *next;
+ int elem[];
+} EL;
+el_t a, c;
+void *b;
+void *fn1() {
+ if (b)
+ return a.elem;
+ return c.elem;
+}
+typedef struct {
+ int x;
+} EV_T;
+EV_T *d;
+void fn2() {
+ EV_T *e = (EV_T *)fn1();
+ d[0] = *e;
+}