+2019-05-03 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/87314
+ * match.pd (cmp (convert1?@2 addr@0) (convert2? addr@1)):
+ Handle STRING_CST vs DECL or STRING_CST.
+
2019-05-03 Richard Biener <rguenther@suse.de>
PR tree-optimization/88963
equal = (base0 == base1);
if (equal == 0)
{
- if (!DECL_P (base0) || !DECL_P (base1))
+ HOST_WIDE_INT ioff0 = -1, ioff1 = -1;
+ off0.is_constant (&ioff0);
+ off1.is_constant (&ioff1);
+ if ((DECL_P (base0) && TREE_CODE (base1) == STRING_CST)
+ || (TREE_CODE (base0) == STRING_CST && DECL_P (base1))
+ || (TREE_CODE (base0) == STRING_CST
+ && TREE_CODE (base1) == STRING_CST
+ && ioff0 >= 0 && ioff1 >= 0
+ && ioff0 < TREE_STRING_LENGTH (base0)
+ && ioff1 < TREE_STRING_LENGTH (base1)
+ /* This is a too conservative test that the STRING_CSTs
+ will not end up being string-merged. */
+ && strncmp (TREE_STRING_POINTER (base0) + ioff0,
+ TREE_STRING_POINTER (base1) + ioff1,
+ MIN (TREE_STRING_LENGTH (base0) - ioff0,
+ TREE_STRING_LENGTH (base1) - ioff1)) != 0))
+ ;
+ else if (!DECL_P (base0) || !DECL_P (base1))
equal = 2;
else if (cmp != EQ_EXPR && cmp != NE_EXPR)
equal = 2;
+2019-05-03 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/87314
+ * gcc.dg/pr87314-1.c: New testcase.
+
2019-05-03 Richard Biener <rguenther@suse.de>
PR tree-optimization/88963
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-original" } */
+
+int f(){ int a; return &a==(void *)"hello"; }
+int g(){ return "bye"=="hello"; }
+int h() { return "bye"=="hellobye"+5; }
+
+/* { dg-final { scan-tree-dump-times "hello" 1 "original" } } */
+/* The test in h() should be retained because the result depends on
+ string merging. */
+/* { dg-final { scan-assembler "hello" } } */