From 5004bd0026e9d57e17ff7c9f8e41a8c0f6e904c5 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson@google.com>
Date: Fri, 14 Nov 2014 06:35:35 +0000
Subject: [PATCH] re PR tree-optimization/63841 (Incorrect strlen optimization
 after complete unroll)

2014-11-13  Teresa Johnson  <tejohnson@google.com>

gcc:
	PR tree-optimization/63841
	* tree-ssa-strlen.c (strlen_optimize_stmt): Ignore clobbers.

2014-11-13  Teresa Johnson  <tejohnson@google.com>

gcc/testsuite:
	PR tree-optimization/63841
	* g++.dg/tree-ssa/pr63841.C: Remove prints, use abort.

From-SVN: r217537
---
 gcc/ChangeLog                           | 10 ++++++++++
 gcc/testsuite/ChangeLog                 | 10 ++++++++++
 gcc/testsuite/g++.dg/tree-ssa/pr63841.C |  7 ++-----
 gcc/tree-ssa-strlen.c                   |  2 +-
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1d20459bc7a8..b7b72dabccfc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-13  Teresa Johnson  <tejohnson@google.com>
+
+	PR tree-optimization/63841
+	* tree-ssa-strlen.c (strlen_optimize_stmt): Ignore clobbers.
+
 2014-11-14  Bin Cheng  <bin.cheng@arm.com>
 
 	* timevar.def (TV_SCHED_FUSION): New time var.
@@ -103,6 +108,11 @@
 	* ipa-profile.c: Likewise.
 	* tree-ssa-loop-ivcanon.c: Fix typo in comments and debugging dumps.
 
+2014-11-13  Teresa Johnson  <tejohnson@google.com>
+
+	PR tree-optimization/63841
+	* tree-ssa-strlen.c (strlen_optimize_stmt): Ignore clobbers.
+
 2014-11-13  Teresa Johnson  <tejohnson@google.com>
 
 	PR tree-optimization/63841
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1e9bc39f087..0c2e465b6ca5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-13  Teresa Johnson  <tejohnson@google.com>
+
+	PR tree-optimization/63841
+	* g++.dg/tree-ssa/pr63841.C: Remove prints, use abort.
+
 2014-11-14  Bin Cheng  <bin.cheng@arm.com>
 
 	* gcc.target/arm/ldrd-strd-pair-1.c: New test.
@@ -8,6 +13,11 @@
 	PR debug/63581
 	* g++.dg/tree-prof/pr63581.C: New test.
 
+2014-11-13  Teresa Johnson  <tejohnson@google.com>
+
+	PR tree-optimization/63841
+	* g++.dg/tree-ssa/pr63841.C: Remove prints, use abort.
+
 2014-11-13  Teresa Johnson  <tejohnson@google.com>
 
 	PR tree-optimization/63841
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr63841.C b/gcc/testsuite/g++.dg/tree-ssa/pr63841.C
index 466e320d431c..2a2c78f9fb25 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr63841.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr63841.C
@@ -1,7 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-O2" } */
 
-#include <cstdio>
 #include <string>
 
 std::string __attribute__ ((noinline)) comp_test_write() {
@@ -29,10 +28,8 @@ std::string __attribute__ ((noinline)) comp_test_write_good() {
 
 int main() {
   std::string good = comp_test_write_good();
-  printf("expected: %hx\n", *(short*)good.c_str());
-
   std::string bad = comp_test_write();
-  printf("got: %hx\n", *(short*)bad.c_str());
 
-  return good != bad;
+  if (good != bad)
+    __builtin_abort ();
 }
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index c224fd9a3f8a..3789e30449d9 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -1934,7 +1934,7 @@ strlen_optimize_stmt (gimple_stmt_iterator *gsi)
 	    break;
 	  }
     }
-  else if (is_gimple_assign (stmt))
+  else if (is_gimple_assign (stmt) && !gimple_clobber_p (stmt))
     {
       tree lhs = gimple_assign_lhs (stmt);
 
-- 
GitLab