re PR tree-optimization/65014 (ice with error: type mismatch in shift expression)
authorJakub Jelinek <jakub@redhat.com>
Thu, 12 Feb 2015 09:45:27 +0000 (10:45 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 12 Feb 2015 09:45:27 +0000 (10:45 +0100)
PR tree-optimization/65014
* fold-const.c (fold_binary_loc): When creating {L,R}ROTATE_EXPR,
use original second operand of arg0 or arg1 instead of
that adjusted by STRIP_NOPS.

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

From-SVN: r220640

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

index c9ac04539cc30dfbdb8f9d5739451da2572f162a..723c62e2d150a751f6e8a0610cab65a31f75bcee 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/65014
+       * fold-const.c (fold_binary_loc): When creating {L,R}ROTATE_EXPR,
+       use original second operand of arg0 or arg1 instead of
+       that adjusted by STRIP_NOPS.
+
 2015-02-11  Jeff Law  <law@redhat.com>
 
        PR target/63347
index b4301c78f30d6575a247e47f1677006e35262d85..83771207c49bc919eb3e040f54b3b940736e00ac 100644 (file)
@@ -10261,7 +10261,9 @@ fold_binary_loc (location_t loc,
                tem = build2_loc (loc, LROTATE_EXPR,
                                  TREE_TYPE (TREE_OPERAND (arg0, 0)),
                                  TREE_OPERAND (arg0, 0),
-                                 code0 == LSHIFT_EXPR ? tree01 : tree11);
+                                 code0 == LSHIFT_EXPR
+                                 ? TREE_OPERAND (arg0, 1)
+                                 : TREE_OPERAND (arg1, 1));
                return fold_convert_loc (loc, type, tem);
              }
            else if (code11 == MINUS_EXPR)
@@ -10283,7 +10285,8 @@ fold_binary_loc (location_t loc,
                                               ? LROTATE_EXPR
                                               : RROTATE_EXPR),
                                              TREE_TYPE (TREE_OPERAND (arg0, 0)),
-                                             TREE_OPERAND (arg0, 0), tree01));
+                                             TREE_OPERAND (arg0, 0),
+                                             TREE_OPERAND (arg0, 1)));
              }
            else if (code01 == MINUS_EXPR)
              {
@@ -10304,7 +10307,7 @@ fold_binary_loc (location_t loc,
                                ? LROTATE_EXPR
                                : RROTATE_EXPR),
                               TREE_TYPE (TREE_OPERAND (arg0, 0)),
-                              TREE_OPERAND (arg0, 0), tree11));
+                              TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 1)));
              }
          }
       }
index 8d5d3f3725d6df1e6d2110c7d01bf6c482b7eb84..dfd7230fda4849a7588ed2cb5d75b55808dccdc9 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/65014
+       * gcc.c-torture/compile/pr65014.c: New test.
+
 2015-02-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/57822
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65014.c b/gcc/testsuite/gcc.c-torture/compile/pr65014.c
new file mode 100644 (file)
index 0000000..c76e957
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR tree-optimization/65014 */
+/* { dg-do compile { target int32plus } } */
+
+extern int x;
+
+unsigned
+foo (unsigned int y)
+{
+  return (y << ((__INTPTR_TYPE__) &x)) | (y >> (32 - ((__INTPTR_TYPE__) &x)));
+}