]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/71693 (ICE: verify_gimple failed (type mismatch in shift expression...
authorJakub Jelinek <jakub@redhat.com>
Thu, 30 Jun 2016 09:17:17 +0000 (11:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 30 Jun 2016 09:17:17 +0000 (11:17 +0200)
PR middle-end/71693
* fold-const.c (fold_binary_loc) <case RROTATE_EXPR>: Cast
TREE_OPERAND (arg0, 0) and TREE_OPERAND (arg0, 1) to type
first when permuting bitwise operation with rotate.  Cast
TREE_OPERAND (arg0, 0) to type when cancelling two rotations.

* gcc.c-torture/compile/pr71693.c: New test.

From-SVN: r237878

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

index dbe7301ef91376c6e741ea79d14def9bf76cdb3e..725d5aac29fc9560d05a62031cff13e509f95766 100644 (file)
@@ -1,3 +1,11 @@
+2016-06-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71693
+       * fold-const.c (fold_binary_loc) <case RROTATE_EXPR>: Cast
+       TREE_OPERAND (arg0, 0) and TREE_OPERAND (arg0, 1) to type
+       first when permuting bitwise operation with rotate.  Cast
+       TREE_OPERAND (arg0, 0) to type when cancelling two rotations.
+
 2016-06-21  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2016-06-21 trunk r237639.
index 8e32c7222b569bd43fcaacd21e461cfbb5c8f02f..0f284020d49dd23b6d07b00a8503670537980a29 100644 (file)
@@ -12746,11 +12746,15 @@ fold_binary_loc (location_t loc,
              || TREE_CODE (arg0) == BIT_IOR_EXPR
              || TREE_CODE (arg0) == BIT_XOR_EXPR)
          && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
-       return fold_build2_loc (loc, TREE_CODE (arg0), type,
-                           fold_build2_loc (loc, code, type,
-                                        TREE_OPERAND (arg0, 0), arg1),
-                           fold_build2_loc (loc, code, type,
-                                        TREE_OPERAND (arg0, 1), arg1));
+       {
+         tree arg00 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
+         tree arg01 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1));
+         return fold_build2_loc (loc, TREE_CODE (arg0), type,
+                                 fold_build2_loc (loc, code, type,
+                                                  arg00, arg1),
+                                 fold_build2_loc (loc, code, type,
+                                                  arg01, arg1));
+       }
 
       /* Two consecutive rotates adding up to the precision of the
         type can be ignored.  */
@@ -12762,7 +12766,7 @@ fold_binary_loc (location_t loc,
          && ((TREE_INT_CST_LOW (arg1)
               + TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)))
              == prec))
-       return TREE_OPERAND (arg0, 0);
+       return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
 
       /* Fold (X & C2) << C1 into (X << C1) & (C2 << C1)
              (X & C2) >> C1 into (X >> C1) & (C2 >> C1)
index 0cd3bba47f49a26f76254380ce04a19b2ae2ed03..9564581837da4641fb1265e0ed07f7429d817c8e 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/71693
+       * gcc.c-torture/compile/pr71693.c: New test.
+
 2016-06-20  Georg-Johann Lay  <avr@gjlay.de>
            Pitchumani Sivanupandi  <pitchumani.s@atmel.com>
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr71693.c b/gcc/testsuite/gcc.c-torture/compile/pr71693.c
new file mode 100644 (file)
index 0000000..fc9249c
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR middle-end/71693 */
+
+unsigned short v;
+
+void
+foo (int x)
+{
+  v = ((((unsigned short) (0x0001 | (x & 0x0070) | 0x0100) & 0x00ffU) << 8)
+       | (((unsigned short) (0x0001 | (x & 0x0070) | 0x0100) >> 8) & 0x00ffU));
+}