This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fold strstr (s, t) eq/ne s to strcmp (s, t) eq/ne 0 if strlen (t) is known


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]