re PR tree-optimization/17512 (ICE in regex.c)
authorKazu Hirata <kazu@cs.umass.edu>
Wed, 22 Sep 2004 18:02:08 +0000 (18:02 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Wed, 22 Sep 2004 18:02:08 +0000 (18:02 +0000)
PR tree-optimization/17512
* convert.c (convert_to_integer): Don't handle TRUTH_*_EXPR as
special cases.

* testsuite/gcc.c-torture/compile/20040916-1.c.

From-SVN: r87870

gcc/ChangeLog
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20040916-1.c [new file with mode: 0644]

index 4ebfab5e835cec34af770353cf759dec6840fdce..4ee9eda85e9e0f4c137c4028901d681c7109ede9 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-22  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/17512
+       * convert.c (convert_to_integer): Don't handle TRUTH_*_EXPR as
+       special cases.
+
 2004-09-22  David Edelsohn  <edelsohn@gnu.org>
 
        * dbxout.c (get_lang_number): Do not define if
index d9c0c129d7cf59af5da36effb264ea138dcc1fd6..005d3e2089b2c2c50e481025a1791678070919e2 100644 (file)
@@ -397,9 +397,7 @@ convert_to_integer (tree type, tree expr)
     case BOOLEAN_TYPE:
     case CHAR_TYPE:
       /* If this is a logical operation, which just returns 0 or 1, we can
-        change the type of the expression.  For some logical operations,
-        we must also change the types of the operands to maintain type
-        correctness.  */
+        change the type of the expression.  */
 
       if (TREE_CODE_CLASS (ex_form) == tcc_comparison)
        {
@@ -408,25 +406,6 @@ convert_to_integer (tree type, tree expr)
          return expr;
        }
 
-      else if (ex_form == TRUTH_AND_EXPR || ex_form == TRUTH_ANDIF_EXPR
-              || ex_form == TRUTH_OR_EXPR || ex_form == TRUTH_ORIF_EXPR
-              || ex_form == TRUTH_XOR_EXPR)
-       {
-         expr = copy_node (expr);
-         TREE_OPERAND (expr, 0) = convert (type, TREE_OPERAND (expr, 0));
-         TREE_OPERAND (expr, 1) = convert (type, TREE_OPERAND (expr, 1));
-         TREE_TYPE (expr) = type;
-         return expr;
-       }
-
-      else if (ex_form == TRUTH_NOT_EXPR)
-       {
-         expr = copy_node (expr);
-         TREE_OPERAND (expr, 0) = convert (type, TREE_OPERAND (expr, 0));
-         TREE_TYPE (expr) = type;
-         return expr;
-       }
-
       /* If we are widening the type, put in an explicit conversion.
         Similarly if we are not changing the width.  After this, we know
         we are truncating EXPR.  */
index fb20f329643cdc69ff14b5d8c7c2038d949530c5..d6226d5f85d116acd3dfc0b44b8a82f9b83cd1fc 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-22  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/17512
+       * gcc.c-torture/compile/20040916-1.c.
+
 2004-09-21  Mark Mitchell  <mark@codesourcery.com>
 
        * gcc.dg/pragma-re-3.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040916-1.c b/gcc/testsuite/gcc.c-torture/compile/20040916-1.c
new file mode 100644 (file)
index 0000000..1a6a9f4
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR tree-optimization/17512
+
+   We used to try to fold "(char) (X ^ Y)", where '^' is
+   TRUTH_XOR_EXPR into ((char) X ^ (char) Y), creating TRUTH_XOR_EXPR
+   with its operands being of type char, which is invalid.  */
+
+char
+foo (int p)
+{
+  int q = p;
+  return (p != 0) == (p == q);
+}