On Tue, Jun 24, 2014 at 1:29 PM, Prathamesh Kulkarni
<bilbotheelffri...@gmail.com> wrote:
> This patch factors out checking expression-code in gimple-match-head.c
>
> * gimple-match-head.c (check_gimple_assign): New function.
>     (check_gimple_assign_convert): Likewise.
>     (check_gimple_call_builtin): Likewise.
>
> * genmatch.c (dt_operand::gen_gimple_expr_expr): Add argument const char *.
>      Generate call to gimple_assign_check or check_gimple_assign_convert.
>     (dt_operand::gen_gimple_expr_fn): Add argument const char *.
>       Generate call to check_gimple_call_builtin.
>     (decision_tree::gen_gimple): Generate definition of def_stmt.

Hmm, I think we should rather try to optimize the repeated

  if (TREE_CODE (op) == SSA_NAME)
    {
       gimple def_stmt = SSA_NAME_DEF_STMT (op);
       if (is_gimple_assign (def_stmt)
....

so that we can eventually directly generate sth like

   if (TREE_CODE (op) == SSA_NAME)
    {
      gimple def_stmt = SSA_NAME_DEF_STMT (op);
      if (is_gimple_assign (def_stmt))
        {
           switch (gimple_assign_rhs_code (def_stmt))
             {
             case PLUS_EXPR:
...

but let's leave that for later.  The generated code doesn't have to be pretty,
it just has to work (and if, then we want to optimize it for speed).

Btw, there are still no early outs in the generated code so we always backtrack
and try other alternatives.  And if we have

(match_and_simplify
  (MINUS_EXPR (PLUS_EXPR @0 @1) @2)
  @1)
(match_and_simplify
  (MINUS_EXPR @0 @1)
  if (integer_zerop (@1))
  @0)

we should try to match the more specific pattern first (we do), but if that
ultimately fails we should execute simplifes that can still match (that
is, we should backtrack only to 'true' dt nodes).

Richard.

> Thanks and Regards,
> Prathamesh.

Reply via email to