PR tree-optimization/65014
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Feb 2015 09:45:27 +0000 (09:45 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Feb 2015 09:45:27 +0000 (09:45 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220640 138bc75d-0d04-0410-961f-82ee72b054a4

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

index c9ac045..723c62e 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 b4301c7..8377120 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 8d5d3f3..dfd7230 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)));
+}