aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-03-14 10:55:41 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-03-14 10:55:41 +0100
commitc2f41ffd2447492ac54381162abe1aceed58812d (patch)
tree0dcab7b94a93edb6c043b8c0f77d70876a60e8a2 /gcc
parenta4b55f2a303636e3491250e1499e88454cb4ed2f (diff)
downloadgcc-c2f41ffd2447492ac54381162abe1aceed58812d.zip
gcc-c2f41ffd2447492ac54381162abe1aceed58812d.tar.gz
gcc-c2f41ffd2447492ac54381162abe1aceed58812d.tar.bz2
re PR tree-optimization/65418 (vim miscompilation)
PR tree-optimization/65418 * tree-ssa-reassoc.c (extract_bit_test_mask): If there are casts in the first PLUS_EXPR operand, ensure tbias and *totallowp are in the inner type. * gcc.c-torture/execute/pr65418-1.c: New test. * gcc.c-torture/execute/pr65418-2.c: New test. From-SVN: r221434
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr65418-1.c19
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr65418-2.c19
-rw-r--r--gcc/tree-ssa-reassoc.c13
5 files changed, 53 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e62f67b..8a38768 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2015-03-14 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/65418
+ * tree-ssa-reassoc.c (extract_bit_test_mask): If there
+ are casts in the first PLUS_EXPR operand, ensure tbias and
+ *totallowp are in the inner type.
+
PR rtl-optimization/65401
* combine.c (rtx_equal_for_field_assignment_p): Add widen_x
argument. If true, adjust_address_nv of x with big-endian
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d9a46cb..e4a92af 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2015-03-14 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/65418
+ * gcc.c-torture/execute/pr65418-1.c: New test.
+ * gcc.c-torture/execute/pr65418-2.c: New test.
+
PR rtl-optimization/65401
* gcc.c-torture/execute/pr65401.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr65418-1.c b/gcc/testsuite/gcc.c-torture/execute/pr65418-1.c
new file mode 100644
index 0000000..54068b3
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr65418-1.c
@@ -0,0 +1,19 @@
+/* PR tree-optimization/65418 */
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ if (x == -216 || x == -132 || x == -218 || x == -146)
+ return 1;
+ return 0;
+}
+
+int
+main ()
+{
+ volatile int i;
+ for (i = -230; i < -120; i++)
+ if (foo (i) != (i == -216 || i == -132 || i == -218 || i == -146))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr65418-2.c b/gcc/testsuite/gcc.c-torture/execute/pr65418-2.c
new file mode 100644
index 0000000..9dc1c66
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr65418-2.c
@@ -0,0 +1,19 @@
+/* PR tree-optimization/65418 */
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ if (x == -216 || x == -211 || x == -218 || x == -205 || x == -223)
+ return 1;
+ return 0;
+}
+
+int
+main ()
+{
+ volatile int i;
+ for (i = -230; i < -200; i++)
+ if (foo (i) != (i == -216 || i == -211 || i == -218 || i == -205 || i == -223))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 2e933e7..77640e5 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2439,26 +2439,25 @@ extract_bit_test_mask (tree exp, int prec, tree totallow, tree low, tree high,
&& TREE_CODE (exp) == PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
{
+ tree ret = TREE_OPERAND (exp, 0);
+ STRIP_NOPS (ret);
widest_int bias
= wi::neg (wi::sext (wi::to_widest (TREE_OPERAND (exp, 1)),
TYPE_PRECISION (TREE_TYPE (low))));
- tree tbias = wide_int_to_tree (TREE_TYPE (low), bias);
+ tree tbias = wide_int_to_tree (TREE_TYPE (ret), bias);
if (totallowp)
{
*totallowp = tbias;
- exp = TREE_OPERAND (exp, 0);
- STRIP_NOPS (exp);
- return exp;
+ return ret;
}
else if (!tree_int_cst_lt (totallow, tbias))
return NULL_TREE;
+ bias = wi::to_widest (tbias);
bias -= wi::to_widest (totallow);
if (wi::ges_p (bias, 0) && wi::lts_p (bias, prec - max))
{
*mask = wi::lshift (*mask, bias);
- exp = TREE_OPERAND (exp, 0);
- STRIP_NOPS (exp);
- return exp;
+ return ret;
}
}
}