This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/14841] [tree-ssa] const_array[CST] is not folded
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 May 2006 10:07:14 -0000
- Subject: [Bug tree-optimization/14841] [tree-ssa] const_array[CST] is not folded
- References: <bug-14841-5009@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #22 from rguenth at gcc dot gnu dot org 2006-05-08 10:07 -------
Doesn't really work, it misses support for STRING_CST. See PR22303.
static const char *foo = "?";
char foobar () { return foo[0]; }
Something like the following should fix it (once fold_read_from_constant_string
is fixed):
Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c (revision 113606)
--- tree-ssa-ccp.c (working copy)
*************** fold_const_aggregate_ref (tree t)
*** 1011,1020 ****
}
if (ctor == NULL_TREE
! || TREE_CODE (ctor) != CONSTRUCTOR
|| !TREE_STATIC (ctor))
return NULL_TREE;
/* Get the index. If we have an SSA_NAME, try to resolve it
with the current lattice value for the SSA_NAME. */
idx = TREE_OPERAND (t, 1);
--- 1011,1024 ----
}
if (ctor == NULL_TREE
! || TREE_CODE (ctor) != CONSTRUCTOR
|| !TREE_STATIC (ctor))
return NULL_TREE;
/* Get the index. If we have an SSA_NAME, try to resolve it
with the current lattice value for the SSA_NAME. */
idx = TREE_OPERAND (t, 1);
--- 1011,1024 ----
}
if (ctor == NULL_TREE
! || (TREE_CODE (ctor) != CONSTRUCTOR
! && TREE_CODE (ctor) != STRING_CST)
|| !TREE_STATIC (ctor))
return NULL_TREE;
+ if (TREE_CODE (ctor) == STRING_CST)
+ return fold_read_from_constant_string (t);
+
/* Get the index. If we have an SSA_NAME, try to resolve it
with the current lattice value for the SSA_NAME. */
idx = TREE_OPERAND (t, 1);
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |22303
nThis| |
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14841