On Wed, May 16, 2018 at 7:14 PM, Kugan Vivekanandarajah
<kugan.vivekanandara...@linaro.org> wrote:
> As mentioned in the PR, I am trying to add ABSU_EXPR to fix this
> issue. In the attached patch, in fold_cond_expr_with_comparison I am
> generating ABSU_EXPR for these cases. As I understand, absu_expr is
> well defined in RTL. So, the issue is generating absu_expr  and
> transferring to RTL in the correct way. I am not sure I am not doing
> all that is needed. I will clean up and add more test-cases based on
> the feedback.


diff --git a/gcc/optabs-tree.c b/gcc/optabs-tree.c
index 71e172c..2b812e5 100644
--- a/gcc/optabs-tree.c
+++ b/gcc/optabs-tree.c
@@ -235,6 +235,7 @@ optab_for_tree_code (enum tree_code code, const_tree type,
       return trapv ? negv_optab : neg_optab;

     case ABS_EXPR:
+    case ABSU_EXPR:
       return trapv ? absv_optab : abs_optab;


This part is not correct, it should something like this:

     case ABS_EXPR:
       return trapv ? absv_optab : abs_optab;
+    case ABSU_EXPR:
+       return abs_optab ;

Because ABSU is not undefined at the TYPE_MAX.

Thanks,
Andrew

>
> Thanks,
> Kugan
>
>
> gcc/ChangeLog:
>
> 2018-05-13  Kugan Vivekanandarajah  <kugan.vivekanandara...@linaro.org>
>
>     * expr.c (expand_expr_real_2): Handle ABSU_EXPR.
>     * fold-const.c (fold_cond_expr_with_comparison): Generate ABSU_EXPR
>     (fold_unary_loc): Handle ABSU_EXPR.
>     * optabs-tree.c (optab_for_tree_code): Likewise.
>     * tree-cfg.c (verify_expr): Likewise.
>     (verify_gimple_assign_unary):  Likewise.
>     * tree-if-conv.c (fold_build_cond_expr):  Likewise.
>     * tree-inline.c (estimate_operator_cost):  Likewise.
>     * tree-pretty-print.c (dump_generic_node):  Likewise.
>     * tree.def (ABSU_EXPR): New.
>
> gcc/testsuite/ChangeLog:
>
> 2018-05-13  Kugan Vivekanandarajah  <kugan.vivekanandara...@linaro.org>
>
>     * gcc.dg/absu.c: New test.

Reply via email to