From: Dirk Mueller Date: Tue, 9 May 2006 14:16:50 +0000 (+0000) Subject: re PR middle-end/27498 (fold does not fold reads from constant static strings) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f9c3744b7f05d9e60ff8776111ad9049b55d863a;p=gcc.git re PR middle-end/27498 (fold does not fold reads from constant static strings) 2006-05-09 Dirk Mueller Richard Guenther PR middle-end/27498 * fold-const.c (fold_read_from_constant_string): Relax check for matching types to matching modes. * gcc.dg/tree-ssa/pr27498.c: New testcase. Co-Authored-By: Richard Guenther From-SVN: r113651 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c1896d9d9b1..b7840c4a28f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-05-09 Dirk Mueller + Richard Guenther + + PR middle-end/27498 + * fold-const.c (fold_read_from_constant_string): Relax check + for matching types to matching modes. + 2006-05-09 Zdenek Dvorak PR rtl-optimization/27335 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 567168276e1..26e53c0c32c 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12220,7 +12220,7 @@ fold_read_from_constant_string (tree exp) } if (string - && TREE_TYPE (exp) == TREE_TYPE (TREE_TYPE (string)) + && TYPE_MODE (TREE_TYPE (exp)) == TYPE_MODE (TREE_TYPE (TREE_TYPE (string))) && TREE_CODE (string) == STRING_CST && TREE_CODE (index) == INTEGER_CST && compare_tree_int (index, TREE_STRING_LENGTH (string)) < 0 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a3f49f7974c..9eff9f48d40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-05-09 Dirk Mueller + Richard Guenther + + PR middle-end/27498 + * gcc.dg/tree-ssa/pr27498.c: New testcase. + 2006-05-09 Zdenek Dvorak PR rtl-optimization/27335 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr27498.c b/gcc/testsuite/gcc.dg/tree-ssa/pr27498.c new file mode 100644 index 00000000000..75d3d4bacd8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr27498.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +void zconfdump(void) +{ + char *p, *p2; + for (p2 = p; p2; ) + { + char __a0, __a1, __a2; + __a0 = ((__const char *) ("\"\\"))[0]; + if (__a0) + return; + } +} + +/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */