diff mbox

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

Message ID 1932856705.289727.1311764346893.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com
State New
Headers show

Commit Message

Kai Tietz July 27, 2011, 10:59 a.m. UTC
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

Comments

Richard Biener July 27, 2011, 11:16 a.m. UTC | #1
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.  */
>
diff mbox

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.  */