This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Optimize reads from constant strings
- From: Richard Henderson <rth at redhat dot com>
- To: law at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Aug 2003 10:50:33 -0700
- Subject: Re: [tree-ssa] Optimize reads from constant strings
- References: <200308141532.h7EFW9tF002309@speedy.slc.redhat.com>
On Thu, Aug 14, 2003 at 09:32:08AM -0600, law@redhat.com wrote:
> + if (string
> + && TREE_CODE (string) == STRING_CST
> + && TREE_CODE (index) == INTEGER_CST
> + && compare_tree_int (index, TREE_STRING_LENGTH (string)) < 0)
> + return build_int_2 ((TREE_STRING_POINTER (string)
> + [TREE_INT_CST_LOW (index)]), 0);
Don't you need to check the type of the string as well?
Otherwise won't you do the wrong thing with
void foo ()
{
if (L"\u1234"[0] != L'\u1234')
abort ();
}
Although, I would think we ought to be able to use link_error
here -- if we don't optimize this we should.
r~