aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/doc/invoke.texi3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-43.c12
-rw-r--r--gcc/tree-ssa-ccp.cc4
3 files changed, 18 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index cb40b38..1337197 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -13208,7 +13208,8 @@ disclosure and use.
GCC still considers an automatic variable that doesn't have an explicit
initializer as uninitialized, @option{-Wuninitialized} and
@option{-Wanalyzer-use-of-uninitialized-value} will still report
-warning messages on such automatic variables.
+warning messages on such automatic variables and the compiler will
+perform optimization as if the variable were uninitialized.
With this option, GCC will also initialize any padding of automatic variables
that have structure or union types to zeroes.
However, the current implementation cannot initialize automatic variables that
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-43.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-43.c
new file mode 100644
index 0000000..3e0a3d6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-43.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O -ftrivial-auto-var-init=zero -fdump-tree-ccp1" } */
+
+int foo (int flag)
+{
+ int i;
+ if (flag)
+ i = 1;
+ return i;
+}
+
+/* { dg-final { scan-tree-dump "return 1;" "ccp1" } } */
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index 68e69bf..0d47289 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -722,6 +722,10 @@ likely_value (gimple *stmt)
if (gimple_has_volatile_ops (stmt))
return VARYING;
+ /* .DEFERRED_INIT produces undefined. */
+ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
+ return UNDEFINED;
+
/* Arrive here for more complex cases. */
has_constant_operand = false;
has_undefined_operand = false;