Patchwork [tree-optimization] : Handle boolean-type case in canonicalize_cond_expr_cond

login
register
mail settings
Submitter Kai Tietz
Date July 27, 2011, 10:59 a.m.
Message ID <1932856705.289727.1311764346893.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
Download mbox | patch
Permalink /patch/107026/
State New
Headers show

Comments

Kai Tietz - July 27, 2011, 10:59 a.m.
Hello,

this patch handles for canonicalize_cond_expr_cond the case, that we have an
type-cast from boolean-type.

ChangeLog

2011-07-27  Kai Tietz  <ktietz@redhat.com>

        * gimple.c (canonicalize_cond_expr_cond): Handle cast
        from boolean-type case.

Bootstrapped and regression tested on x86_64-pc-linux-gnu.  Ok for apply?

Regards,
Kai
Richard Guenther - July 27, 2011, 11:16 a.m.
n Wed, Jul 27, 2011 at 12:59 PM, Kai Tietz <ktietz@redhat.com> wrote:
> Hello,
>
> this patch handles for canonicalize_cond_expr_cond the case, that we have an
> type-cast from boolean-type.
>
> ChangeLog
>
> 2011-07-27  Kai Tietz  <ktietz@redhat.com>
>
>        * gimple.c (canonicalize_cond_expr_cond): Handle cast
>        from boolean-type case.
>
> Bootstrapped and regression tested on x86_64-pc-linux-gnu.  Ok for apply?

Ok.  Do you have a testcase that you can add?

Thanks,
Richard.

> Regards,
> Kai
>
> Index: gcc-head/gcc/gimple.c
> ===================================================================
> --- gcc-head.orig/gcc/gimple.c
> +++ gcc-head/gcc/gimple.c
> @@ -3160,7 +3160,9 @@ canonicalize_cond_expr_cond (tree t)
>  {
>   /* Strip conversions around boolean operations.  */
>   if (CONVERT_EXPR_P (t)
> -      && truth_value_p (TREE_CODE (TREE_OPERAND (t, 0))))
> +      && (truth_value_p (TREE_CODE (TREE_OPERAND (t, 0)))
> +         || TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0)))
> +            == BOOLEAN_TYPE))
>     t = TREE_OPERAND (t, 0);
>
>   /* For !x use x == 0.  */
>

Patch

Index: gcc-head/gcc/gimple.c
===================================================================
--- gcc-head.orig/gcc/gimple.c
+++ gcc-head/gcc/gimple.c
@@ -3160,7 +3160,9 @@  canonicalize_cond_expr_cond (tree t)
 {
   /* Strip conversions around boolean operations.  */
   if (CONVERT_EXPR_P (t)
-      && truth_value_p (TREE_CODE (TREE_OPERAND (t, 0))))
+      && (truth_value_p (TREE_CODE (TREE_OPERAND (t, 0)))
+         || TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0)))
+            == BOOLEAN_TYPE))
     t = TREE_OPERAND (t, 0);

   /* For !x use x == 0.  */