]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/38865 (missing FRE with VIEW_CONVERT_EXPR)
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Fri, 12 Jun 2009 19:00:39 +0000 (19:00 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 12 Jun 2009 19:00:39 +0000 (12:00 -0700)
2009-06-12  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/38865
        * tree-ssa-sccvn.c (visit_reference_op_load): If vn_reference_lookup
        is returns NULL and OP is a VCE, look through the VCE.

2009-06-12  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/38865
        * gcc.dg/tree-ssa/fre-vce-1.c
:

From-SVN: r148437

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 93a0e896d267a7e359aaf1696d6c8e6e73c7f415..2e8f5ebcca2901d5b9ddfa78beacc8456a9ca13e 100644 (file)
@@ -1,3 +1,9 @@
+2009-06-12  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/38865
+       * tree-ssa-sccvn.c (visit_reference_op_load): If vn_reference_lookup
+       is returns NULL and OP is a VCE, look through the VCE.
+
 2009-06-12  Ian Lance Taylor  <iant@google.com>
 
        PR bootstrap/40430
index b5f0fbc1ed395e995aaf884b3bf707821dabbfb1..8c218933be25625d2f98daac9da5d7b071297b43 100644 (file)
@@ -1,3 +1,8 @@
+2009-06-12  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/38865
+       * gcc.dg/tree-ssa/fre-vce-1.c
+
 2009-06-12  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR testsuite/40384
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c b/gcc/testsuite/gcc.dg/tree-ssa/fre-vce-1.c
new file mode 100644 (file)
index 0000000..f8c12c8
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-options "-O2 -fdump-tree-fre -w" } */
+/* { dg-do compile } */
+#define vector __attribute__((vector_size(sizeof(int)*4) ))
+struct s { vector int i; };
+vector float f(struct s *sv)
+{
+  sv->i = (vector int){1, 2, 3, 4};
+  return (vector float)sv->i;
+}
+
+
+vector float f1(struct s *sv, vector int a)
+{
+  sv->i = a;
+  return (vector float)sv->i;
+}
+
+struct s1 { int i; };
+
+void g(struct s1 *, float);
+void a1 (struct s1 sv)
+{
+  sv.i = 1;
+  g(&sv, *(float*)&sv.i);
+}
+
+
+void a2 (struct s1 sv, int i)
+{
+  sv.i = i;
+  g(&sv, *(float*)&sv.i);
+}
+
+/* { dg-final { scan-tree-dump-times "sv_\[0-9\]\\\(D\\\)->i" 2 "fre" } } */
+/* { dg-final { scan-tree-dump-times "sv.i" 2 "fre" } } */
index 03fea751feb698e739b6439f1a412c6528945485..6d263ded1775fe7840ebb9d1cbfa508b53cecd73 100644 (file)
@@ -1976,6 +1976,12 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt)
   bool changed = false;
   tree result = vn_reference_lookup (op, gimple_vuse (stmt), true, NULL);
 
+  /* If we have a VCE, try looking up its operand as it might be stored in
+     a different type.  */
+  if (!result && TREE_CODE (op) == VIEW_CONVERT_EXPR)
+    result = vn_reference_lookup (TREE_OPERAND (op, 0), gimple_vuse (stmt),
+                                 true, NULL);
+
   /* We handle type-punning through unions by value-numbering based
      on offset and size of the access.  Be prepared to handle a
      type-mismatch here via creating a VIEW_CONVERT_EXPR.  */