aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-03-13 09:12:59 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-03-13 09:12:59 +0100
commit9e61e48e12ae2737f4738c37bfe05de726dc0e2e (patch)
treec36e6e8944f9cee6d2772d4dc9cc1540c2728783 /gcc
parentcd471b26ca3923f6ca39105c0efe166248ec0425 (diff)
downloadgcc-9e61e48e12ae2737f4738c37bfe05de726dc0e2e.zip
gcc-9e61e48e12ae2737f4738c37bfe05de726dc0e2e.tar.gz
gcc-9e61e48e12ae2737f4738c37bfe05de726dc0e2e.tar.bz2
re PR middle-end/84834 (ICE: tree check: expected integer_cst, have complex_cst in to_wide, at tree.h:5527)
PR middle-end/84834 * match.pd ((A & C) != 0 ? D : 0): Use INTEGER_CST@2 instead of integer_pow2p@2 and test integer_pow2p in condition. (A < 0 ? C : 0): Similarly for @1. * gcc.dg/pr84834.c: New test. From-SVN: r258479
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/match.pd27
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr84834.c15
4 files changed, 38 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 077dcef..9d48da9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2018-03-13 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/84834
+ * match.pd ((A & C) != 0 ? D : 0): Use INTEGER_CST@2 instead of
+ integer_pow2p@2 and test integer_pow2p in condition.
+ (A < 0 ? C : 0): Similarly for @1.
+
PR middle-end/84831
* stmt.c (parse_output_constraint): If the CONSTRAINT_LEN (*p, p)
characters starting at p contain '\0' character, don't look beyond
diff --git a/gcc/match.pd b/gcc/match.pd
index 5ba1304..f61c4d7 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3566,16 +3566,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(cond
(ne (bit_and @0 integer_pow2p@1) integer_zerop)
- integer_pow2p@2 integer_zerop)
- (with {
- int shift = (wi::exact_log2 (wi::to_wide (@2))
- - wi::exact_log2 (wi::to_wide (@1)));
- }
- (if (shift > 0)
- (bit_and
- (lshift (convert @0) { build_int_cst (integer_type_node, shift); }) @2)
- (bit_and
- (convert (rshift @0 { build_int_cst (integer_type_node, -shift); })) @2))))
+ INTEGER_CST@2 integer_zerop)
+ (if (integer_pow2p (@2))
+ (with {
+ int shift = (wi::exact_log2 (wi::to_wide (@2))
+ - wi::exact_log2 (wi::to_wide (@1)));
+ }
+ (if (shift > 0)
+ (bit_and
+ (lshift (convert @0) { build_int_cst (integer_type_node, shift); }) @2)
+ (bit_and
+ (convert (rshift @0 { build_int_cst (integer_type_node, -shift); }))
+ @2)))))
/* If we have (A & C) != 0 where C is the sign bit of A, convert
this into A < 0. Similarly for (A & C) == 0 into A >= 0. */
@@ -3595,8 +3597,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(cond
(lt @0 integer_zerop)
- integer_pow2p@1 integer_zerop)
- (if (!TYPE_UNSIGNED (TREE_TYPE (@0)))
+ INTEGER_CST@1 integer_zerop)
+ (if (integer_pow2p (@1)
+ && !TYPE_UNSIGNED (TREE_TYPE (@0)))
(with {
int shift = element_precision (@0) - wi::exact_log2 (wi::to_wide (@1)) - 1;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index db73151..8e9c2ef 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2018-03-13 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/84834
+ * gcc.dg/pr84834.c: New test.
+
PR target/84827
* gcc.target/i386/pr84827.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr84834.c b/gcc/testsuite/gcc.dg/pr84834.c
new file mode 100644
index 0000000..38c056b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr84834.c
@@ -0,0 +1,15 @@
+/* PR middle-end/84834 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+_Complex int
+foo (int a)
+{
+ return a < 0;
+}
+
+_Complex int
+bar (int a)
+{
+ return (a & 8) ? (_Complex int) 16 : (_Complex int) 0;
+}