re PR tree-optimization/35402 (Store CCP will not inline static const variable which...
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Thu, 6 Mar 2008 21:56:04 +0000 (21:56 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 6 Mar 2008 21:56:04 +0000 (13:56 -0800)
2008-03-06  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/35402
        * tree-ssa-ccp.c (get_symbol_constant_value): Handle
        integral and scalar float variables which have a
        NULL DECL_INITIAL.

2008-03-06  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/35402
        * gcc.dg/tree-ssa/ssa-store-ccp-1.c: New test.

From-SVN: r132991

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-1.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 5b3525037d930576ef3509e83ba6f06fb94ea54a..d3a2325d2b6fa3587ce36752ec7bbbb9ad5d1b12 100644 (file)
@@ -1,3 +1,10 @@
+2008-03-06  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/35402
+       * tree-ssa-ccp.c (get_symbol_constant_value): Handle
+       integral and scalar float variables which have a
+       NULL DECL_INITIAL.
+
 2008-03-06  Nathan Froyd  <froydnj@codesourcery.com>
 
        * dwarf2out.c (dwarf2out_frame_debug_expr): Consult the
index 38bf08d7db928e38d9142e0823c7f81fbc558f1d..b24b8daa07b9e65f7e6e323c11c55ff9c11f6a78 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-06  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/35402
+       * gcc.dg/tree-ssa/ssa-store-ccp-1.c: New test.
+
 2008-03-06  Markus Milleder  <markus.milleder@generali.at>
 
        PR preprocessor/35458
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-1.c
new file mode 100644 (file)
index 0000000..aaa3d13
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+static const int conststaticvariable;
+
+int f(void)
+{
+  return conststaticvariable;
+}
+
+/* There should be no reference to conststaticvariable as we should have
+   inlined the 0. */
+/* { dg-final { scan-tree-dump-times "conststaticvariable" 0 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index f9f1217c5fc0e7113d25888aec44b1f81b099779..b9211a5df9c5d3d9058711988a56910da550f33b 100644 (file)
@@ -306,6 +306,12 @@ get_symbol_constant_value (tree sym)
       if (val
          && ccp_decl_initial_min_invariant (val))
        return val;
+      /* Variables declared 'const' without an initializer
+        have zero as the intializer.  */
+      if (!val
+          && (INTEGRAL_TYPE_P (TREE_TYPE (sym))
+              || SCALAR_FLOAT_TYPE_P (TREE_TYPE (sym))))
+        return fold_convert (TREE_TYPE (sym), integer_zero_node);
     }
 
   return NULL_TREE;