+2019-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/88693
+ * tree-ssa-strlen.c (get_min_string_length): Don't set *full_string_p
+ for STRING_CSTs that don't contain any NUL characters in the first
+ TREE_STRING_LENGTH bytes.
+
2019-01-11 Alan Modra <amodra@gmail.com>
PR 88777
+2019-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/88693
+ * gcc.c-torture/execute/pr88693.c: New test.
+
2019-01-11 Tamar Christina <tamar.christina@arm.com>
* gcc.target/aarch64/advsimd-intrinsics/vector-complex_f16.c: Require neon
--- /dev/null
+/* PR tree-optimization/88693 */
+
+__attribute__((noipa)) void
+foo (char *p)
+{
+ if (__builtin_strlen (p) != 9)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+quux (char *p)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ if (p[i] != 'x')
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+qux (void)
+{
+ char b[100];
+ __builtin_memset (b, 'x', sizeof (b));
+ quux (b);
+}
+
+__attribute__((noipa)) void
+bar (void)
+{
+ static unsigned char u[9] = "abcdefghi";
+ char b[100];
+ __builtin_memcpy (b, u, sizeof (u));
+ b[sizeof (u)] = 0;
+ foo (b);
+}
+
+__attribute__((noipa)) void
+baz (void)
+{
+ static unsigned char u[] = { 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r' };
+ char b[100];
+ __builtin_memcpy (b, u, sizeof (u));
+ b[sizeof (u)] = 0;
+ foo (b);
+}
+
+int
+main ()
+{
+ qux ();
+ bar ();
+ baz ();
+ return 0;
+}
if (rhs && TREE_CODE (rhs) == STRING_CST)
{
- *full_string_p = true;
- return strlen (TREE_STRING_POINTER (rhs));
+ HOST_WIDE_INT len = strlen (TREE_STRING_POINTER (rhs));
+ *full_string_p = len < TREE_STRING_LENGTH (rhs);
+ return len;
}
return -1;