public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
@ 2011-05-18 17:14 Kai Tietz
  2011-05-18 19:35 ` Kai Tietz
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2011-05-18 17:14 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Guenther

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

Hello

As follow-up for logical to binary transition

2011-05-18  Kai Tietz  <ktietz@redhat.com>

	* tree-cfg.c (verify_gimple_assign_binary): Barf on
	TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR.
	(gimplify_expr): Boolify TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
	TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR. Additionally
	move TRUTH_AND|OR|XOR_EXPR to its binary form.

Boostrapped for x86_64-pc-linux-gnu and regression tested for ada,
fortran, g++, and c. Ok for apply?

Regards,
Kai

[-- Attachment #2: truth2bin.txt --]
[-- Type: text/plain, Size: 1725 bytes --]

Index: gcc/gcc/gimplify.c
===================================================================
--- gcc.orig/gcc/gimplify.c	2011-05-13 13:15:01.000000000 +0200
+++ gcc/gcc/gimplify.c	2011-05-18 14:03:31.730740200 +0200
@@ -7210,7 +7210,21 @@ gimplify_expr (tree *expr_p, gimple_seq
 		break;
 	      }
 	  }
-	  
+
+	switch (TREE_CODE (*expr_p))
+	  {
+	  case TRUTH_AND_EXPR:
+	    TREE_SET_CODE (*expr_p, BIT_AND_EXPR);
+	    break;
+	  case TRUTH_OR_EXPR:
+	    TREE_SET_CODE (*expr_p, BIT_IOR_EXPR);
+	    break;
+	  case TRUTH_XOR_EXPR:
+	    TREE_SET_CODE (*expr_p, BIT_XOR_EXPR);
+	    break;
+	  default:
+	    break;
+	  }
 	  /* Classified as tcc_expression.  */
 	  goto expr_2;
 
Index: gcc/gcc/tree-cfg.c
===================================================================
--- gcc.orig/gcc/tree-cfg.c	2011-05-18 14:01:18.000000000 +0200
+++ gcc/gcc/tree-cfg.c	2011-05-18 14:05:06.512276000 +0200
@@ -3555,29 +3555,11 @@ do_pointer_plus_expr_check:
 
     case TRUTH_ANDIF_EXPR:
     case TRUTH_ORIF_EXPR:
-      gcc_unreachable ();
-
     case TRUTH_AND_EXPR:
     case TRUTH_OR_EXPR:
     case TRUTH_XOR_EXPR:
-      {
-	/* We require two-valued operand types.  */
-	if (!(TREE_CODE (rhs1_type) == BOOLEAN_TYPE
-	      || (INTEGRAL_TYPE_P (rhs1_type)
-		  && TYPE_PRECISION (rhs1_type) == 1))
-	    || !(TREE_CODE (rhs2_type) == BOOLEAN_TYPE
-		 || (INTEGRAL_TYPE_P (rhs2_type)
-		     && TYPE_PRECISION (rhs2_type) == 1)))
-	  {
-	    error ("type mismatch in binary truth expression");
-	    debug_generic_expr (lhs_type);
-	    debug_generic_expr (rhs1_type);
-	    debug_generic_expr (rhs2_type);
-	    return true;
-	  }
 
-	break;
-      }
+      gcc_unreachable ();
 
     case LT_EXPR:
     case LE_EXPR:

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
  2011-05-18 17:14 [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form Kai Tietz
@ 2011-05-18 19:35 ` Kai Tietz
  2011-05-19 12:31   ` Richard Guenther
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2011-05-18 19:35 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Guenther

2011/5/18 Kai Tietz <ktietz70@googlemail.com>:
> Hello
>
> As follow-up for logical to binary transition
>
> 2011-05-18  Kai Tietz  <ktietz@redhat.com>
>
>        * tree-cfg.c (verify_gimple_assign_binary): Barf on
>        TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR.
>        (gimplify_expr): Boolify TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
>        TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR. Additionally
>        move TRUTH_AND|OR|XOR_EXPR to its binary form.
>
> Boostrapped for x86_64-pc-linux-gnu and regression tested for ada,
> fortran, g++, and c. Ok for apply?

Additional bootstrapped and regression tested for java, obj-c, and
obj-c++. Regression tested alos libstdc++ and libjava. No regressions.

Regards,
Kai

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
  2011-05-18 19:35 ` Kai Tietz
@ 2011-05-19 12:31   ` Richard Guenther
  2011-05-19 12:57     ` Eric Botcazou
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2011-05-19 12:31 UTC (permalink / raw)
  To: Kai Tietz; +Cc: GCC Patches, Eric Botcazou

On Wed, May 18, 2011 at 8:30 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2011/5/18 Kai Tietz <ktietz70@googlemail.com>:
>> Hello
>>
>> As follow-up for logical to binary transition
>>
>> 2011-05-18  Kai Tietz  <ktietz@redhat.com>
>>
>>        * tree-cfg.c (verify_gimple_assign_binary): Barf on
>>        TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR.
>>        (gimplify_expr): Boolify TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
>>        TRUTH_AND_EXPR, TRUTH_OR_EXPR, and TRUTH_XOR_EXPR. Additionally
>>        move TRUTH_AND|OR|XOR_EXPR to its binary form.
>>
>> Boostrapped for x86_64-pc-linux-gnu and regression tested for ada,
>> fortran, g++, and c. Ok for apply?
>
> Additional bootstrapped and regression tested for java, obj-c, and
> obj-c++. Regression tested alos libstdc++ and libjava. No regressions.

Please put a comment before

+
+	switch (TREE_CODE (*expr_p))
+	  {
+	  case TRUTH_AND_EXPR:
+	    TREE_SET_CODE (*expr_p, BIT_AND_EXPR);
+	    break;
+	  case TRUTH_OR_EXPR:
+	    TREE_SET_CODE (*expr_p, BIT_IOR_EXPR);
+	    break;
+	  case TRUTH_XOR_EXPR:
+	    TREE_SET_CODE (*expr_p, BIT_XOR_EXPR);
+	    break;
+	  default:
+	    break;
+	  }

like

/* With two-valued operand types binary truth expressions are
   semantically equivalent to bitwise binary expressions.  Canonicalize
   them to the bitwise variant.  */

Eric, how will this interact with Ada boolean types with 8 bit precision
and those "invalid" values - will invalid values ever enter into
expressions or are they checked before?  Can you think of something
that would break with s/TRUTH_*_EXPR/BIT_*_EXPR/ for Ada?

Thanks,
Richard.

> Regards,
> Kai
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
  2011-05-19 12:31   ` Richard Guenther
@ 2011-05-19 12:57     ` Eric Botcazou
  2011-05-19 12:59       ` Richard Guenther
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Botcazou @ 2011-05-19 12:57 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Kai Tietz, GCC Patches

> Eric, how will this interact with Ada boolean types with 8 bit precision
> and those "invalid" values - will invalid values ever enter into
> expressions or are they checked before?

IIUC the Ada semantics is that they must be checked prior to being used.  Once 
they are used, they are "recycled" into valid values.  So the issue boils down 
to how the check is implemented and it doesn't use TRUTH_(AND|OR|XOR) at all.

> Can you think of something that would break with s/TRUTH_*_EXPR/BIT_*_EXPR/
> for Ada? 

No, not at the moment.  Thanks for asking in any case.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
  2011-05-19 12:57     ` Eric Botcazou
@ 2011-05-19 12:59       ` Richard Guenther
  2011-05-19 13:01         ` Kai Tietz
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2011-05-19 12:59 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: Kai Tietz, GCC Patches

On Thu, May 19, 2011 at 12:45 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Eric, how will this interact with Ada boolean types with 8 bit precision
>> and those "invalid" values - will invalid values ever enter into
>> expressions or are they checked before?
>
> IIUC the Ada semantics is that they must be checked prior to being used.  Once
> they are used, they are "recycled" into valid values.  So the issue boils down
> to how the check is implemented and it doesn't use TRUTH_(AND|OR|XOR) at all.
>
>> Can you think of something that would break with s/TRUTH_*_EXPR/BIT_*_EXPR/
>> for Ada?
>
> No, not at the moment.  Thanks for asking in any case.

Kai, the patch is ok then with the comment added.

Thanks,
Richard.

> --
> Eric Botcazou
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
  2011-05-19 12:59       ` Richard Guenther
@ 2011-05-19 13:01         ` Kai Tietz
  0 siblings, 0 replies; 6+ messages in thread
From: Kai Tietz @ 2011-05-19 13:01 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Eric Botcazou, GCC Patches

2011/5/19 Richard Guenther <richard.guenther@gmail.com>:
> On Thu, May 19, 2011 at 12:45 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> Eric, how will this interact with Ada boolean types with 8 bit precision
>>> and those "invalid" values - will invalid values ever enter into
>>> expressions or are they checked before?
>>
>> IIUC the Ada semantics is that they must be checked prior to being used.  Once
>> they are used, they are "recycled" into valid values.  So the issue boils down
>> to how the check is implemented and it doesn't use TRUTH_(AND|OR|XOR) at all.
>>
>>> Can you think of something that would break with s/TRUTH_*_EXPR/BIT_*_EXPR/
>>> for Ada?
>>
>> No, not at the moment.  Thanks for asking in any case.
>
> Kai, the patch is ok then with the comment added.
>
> Thanks,
> Richard.
>
>> --
>> Eric Botcazou
>>

Committed at revision 173903 with suggested comment.

Regards,
Kai

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-19 11:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 17:14 [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form Kai Tietz
2011-05-18 19:35 ` Kai Tietz
2011-05-19 12:31   ` Richard Guenther
2011-05-19 12:57     ` Eric Botcazou
2011-05-19 12:59       ` Richard Guenther
2011-05-19 13:01         ` Kai Tietz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).