tree-cfg.c (verify_gimple_assign_binary): Barf on TRUTH_AND_EXPR, TRUTH_OR_EXPR,...
authorKai Tietz <ktietz@redhat.com>
Thu, 19 May 2011 11:16:20 +0000 (13:16 +0200)
committerKai Tietz <ktietz@gcc.gnu.org>
Thu, 19 May 2011 11:16:20 +0000 (13:16 +0200)
2011-05-19  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): Move TRUTH_AND|OR|XOR_EXPR to its binary form.

From-SVN: r173903

gcc/ChangeLog
gcc/gimplify.c
gcc/tree-cfg.c

index b9a9c866d99b5256368062b946b456e677c7d685..3da31e700b44cc781f703b36290b74d98442b5d3 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-19  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): Move TRUTH_AND|OR|XOR_EXPR to its binary form.
+
 2011-05-19  Anatoly Sokolov <aesok@post.ru>
            Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
index d776692d71517f3d064db2002bc513d69c9cf3c0..5fd22c011c20570017d286e4d66c67345a2863a4 100644 (file)
@@ -7210,7 +7210,23 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
                break;
              }
          }
-         
+
+         /* With two-valued operand types binary truth expressions are
+            semantically equivalent to bitwise binary expressions.  Canonicalize
+            them to the bitwise variant.  */   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 957f1f1238c32926c13f390bb30001071f3cf9a5..f6b171024bd6d86ed5cd4697d083f2c31646ed9e 100644 (file)
@@ -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: