]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/32780 (ICE in extract_range_from_binary_expr, at tree-vrp.c:1793...
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Sat, 4 Aug 2007 05:21:30 +0000 (05:21 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sat, 4 Aug 2007 05:21:30 +0000 (22:21 -0700)
2007-08-04  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/32780
        * fold-const.c (fold_binary <case MINUS_EXPR>): Fix the type of operands
        for the folding of "A - (A & B)" into "~B & A"; cast them to type.

2007-08-04  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/32780
        * gcc.c-torture/compile/pr32780.c: New test.

From-SVN: r127199

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr32780.c [new file with mode: 0644]

index 33211ce682e39f120872db815374a273f5a8186a..36a43421ec09e044014d0e8a500b72ca3812584d 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-04  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR middle-end/32780
+       * fold-const.c (fold_binary <case MINUS_EXPR>): Fix the type of operands
+       for the folding of "A - (A & B)" into "~B & A"; cast them to type.
+
 2007-08-03  Zdenek Dvorak  <ook@ucw.cz>
 
        * tree-ssa-threadupdate.c (thread_through_all_blocks): Use loops' state
index be46b23e22f15ed71cf3c7c188cfed825c68d0ea..154454a72a472cf220a4877c39f7a06f0799323e 100644 (file)
@@ -9730,15 +9730,19 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
              && TREE_CODE (arg1) == BIT_AND_EXPR)
            {
              if (operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0))
-               return fold_build2 (BIT_AND_EXPR, type,
-                                   fold_build1 (BIT_NOT_EXPR, type,
-                                                TREE_OPERAND (arg1, 0)),
-                                   arg0);
+               {
+                 tree arg10 = fold_convert (type, TREE_OPERAND (arg1, 0));
+                 return fold_build2 (BIT_AND_EXPR, type,
+                                     fold_build1 (BIT_NOT_EXPR, type, arg10),
+                                     fold_convert (type, arg0));
+               }
              if (operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
-               return fold_build2 (BIT_AND_EXPR, type,
-                                   fold_build1 (BIT_NOT_EXPR, type,
-                                                TREE_OPERAND (arg1, 1)),
-                                   arg0);
+               {
+                 tree arg11 = fold_convert (type, TREE_OPERAND (arg1, 1));
+                 return fold_build2 (BIT_AND_EXPR, type,
+                                     fold_build1 (BIT_NOT_EXPR, type, arg11),
+                                     fold_convert (type, arg0));
+               }
            }
 
          /* Fold (A & ~B) - (A & B) into (A ^ B) - B, where B is
index 8814bd2cbaa24c0579c5f809513fa9a615d0f976..9371c1cb04ea158c00d7ccbfc2be7f4849ae051f 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-04  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR middle-end/32780
+       * gcc.c-torture/compile/pr32780.c: New test.
+
 2007-08-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        RP middle-end/32399
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr32780.c b/gcc/testsuite/gcc.c-torture/compile/pr32780.c
new file mode 100644 (file)
index 0000000..cfe64e4
--- /dev/null
@@ -0,0 +1,10 @@
+typedef __SIZE_TYPE__ size_t;
+extern void dont_optimize_away(size_t);
+
+void crashGcc(char*a)
+{
+        size_t b=(size_t)a - ((size_t)a & 1);
+        size_t c=(size_t)a - (b & (size_t)a);
+        dont_optimize_away(b+c);
+}
+