aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-06-30 10:52:43 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-06-30 10:52:43 +0200
commit205cccc7c8ed017684b946dbfef48b9b013c5c51 (patch)
treeb9c50c2ea116fc10568c7c63dc4c245ba9e28da1 /gcc
parent1bcf319ef895a51ad95db857ff1a457485965689 (diff)
downloadgcc-205cccc7c8ed017684b946dbfef48b9b013c5c51.zip
gcc-205cccc7c8ed017684b946dbfef48b9b013c5c51.tar.gz
gcc-205cccc7c8ed017684b946dbfef48b9b013c5c51.tar.bz2
re PR middle-end/71693 (ICE: verify_gimple failed (type mismatch in shift expression, -O0, -O1, -O2, -O3))
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: r237875
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/fold-const.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr71693.c10
4 files changed, 33 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 308fcc8..8d00f72 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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-29 David Malcolm <dmalcolm@redhat.com>
* opts.c (handle_param): Use find_param_fuzzy to offer suggestions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3b9500d..f97b8bf 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -10294,11 +10294,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 some integer
multiple of the precision of the type can be ignored. */
@@ -10307,7 +10311,7 @@ fold_binary_loc (location_t loc,
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
&& wi::umod_trunc (wi::add (arg1, TREE_OPERAND (arg0, 1)),
prec) == 0)
- return TREE_OPERAND (arg0, 0);
+ return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
return NULL_TREE;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8069c67..1828ca6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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-29 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/spellcheck-params.c: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr71693.c b/gcc/testsuite/gcc.c-torture/compile/pr71693.c
new file mode 100644
index 0000000..fc9249c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr71693.c
@@ -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));
+}