From: Kai Tietz <ktietz70@googlemail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Richard Guenther <richard.guenther@gmail.com>
Subject: [patch gimplifier]: Change TRUTH_(AND|OR|XOR) expressions to binary form
Date: Wed, 18 May 2011 17:14:00 -0000 [thread overview]
Message-ID: <BANLkTimA=+9R3_A1scbpY+5qX6QHy6ouRQ@mail.gmail.com> (raw)
[-- 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:
next reply other threads:[~2011-05-18 15:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 17:14 Kai Tietz [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTimA=+9R3_A1scbpY+5qX6QHy6ouRQ@mail.gmail.com' \
--to=ktietz70@googlemail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).