On Thu, Aug 11, 2016 at 04:06:10PM +0530, Prathamesh Kulkarni wrote:
> +static void
> +replace_call_by_cmp (gimple_stmt_iterator *gsi, location_t loc, 
> +                  tree type, tree arg1, tree arg2,
> +                  tree res_type, enum tree_code cmp_code)
> +{
> +  tree ptrtype = build_pointer_type_for_mode (char_type_node, ptr_mode, 
> true);
> +  tree off = build_int_cst (ptrtype, 0);
> +  arg1 = build2_loc (loc, MEM_REF, type, arg1, off);
> +  tree tem1 = fold_const_aggregate_ref (arg1);
> +  if (tem1)
> +    arg1 = tem1;
> +
> +  if (POINTER_TYPE_P (TREE_TYPE (arg2)))
> +    {
> +      arg2 = build2_loc (loc, MEM_REF, type, arg2, off);
> +      tree tem2 = fold_const_aggregate_ref (arg2);
> +      if (tem2)
> +     arg2 = tem2;
> +    }
> +  else
> +    gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (arg2)));
> +
> +  tree res = fold_convert_loc (loc, res_type,
> +                            fold_build2_loc (loc, cmp_code,
> +                                             boolean_type_node,
> +                                             arg1, arg2));
> +
> +  gimplify_and_update_call_from_tree (gsi, res);

I know it is pre-existing, but do you really need to create everything as
trees first and then gimplify?  Can't you emit GIMPLE right away?

> @@ -2505,7 +2558,7 @@ const pass_data pass_data_strlen =
>    0, /* properties_provided */
>    0, /* properties_destroyed */
>    0, /* todo_flags_start */
> -  0, /* todo_flags_finish */
> +  TODO_update_ssa_only_virtuals, /* todo_flags_finish */
>  };
>  
>  class pass_strlen : public gimple_opt_pass

And if you do, I'd hope you can avoid this.  The strlen call has
a vuse, just use the same virtual operand in vuse on the mem read.

        Jakub

Reply via email to