This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fold strstr (s, t) eq/ne s to strcmp (s, t) eq/ne 0 if strlen (t) is known
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- Cc: gcc Patches <gcc-patches at gcc dot gnu dot org>, Richard Biener <rguenther at suse dot de>
- Date: Mon, 5 Dec 2016 19:17:42 +0100
- Subject: Re: Fold strstr (s, t) eq/ne s to strcmp (s, t) eq/ne 0 if strlen (t) is known
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjMn2AWAP9tu+qknHnPEhOAh7Au7Ke4YFGcJeSkfJ=Ts=Zg@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Dec 05, 2016 at 11:32:15PM +0530, Prathamesh Kulkarni wrote:
> So I had to check if SSA_NAME_DEF_STMT (rhs2) was call to strstr
> rather than rhs1.
Then you need to test both whether it is strstr (s, t) == s or
s == strstr (s, t).
> + gassign *ga = gimple_build_assign (lhs, code,
> + strcmp_lhs, zero);
The formatting is wrong here.
> + gsi_replace (&gsi, ga, false);
> + }
> + }
> + }
> + }
> + }
> + }
> else if (TREE_CODE (lhs) != SSA_NAME && !TREE_SIDE_EFFECTS (lhs))
> {
> tree type = TREE_TYPE (lhs);
> @@ -2505,7 +2554,7 @@ const pass_data pass_data_strlen =
> 0, /* properties_provided */
> 0, /* properties_destroyed */
> 0, /* todo_flags_start */
> - 0, /* todo_flags_finish */
> + TODO_update_ssa, /* todo_flags_finish */
No, please don't. Just make sure to build proper SSA right away.
Jakub