aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-07-20 17:13:00 +0000
committerJakub Jelinek <jakub@redhat.com>2019-07-20 17:13:00 +0000
commite3358dd36bd69327e0fe20d9fe2950751c6dfbeb (patch)
tree316f4240bcb8ca389b783c719572a6ecf96ea6ac
parentaf8b31aaac4acc9b82e14375d8f435807b11f4c0 (diff)
PR target/91204
* optabs.c (expand_unop): As fallback, expand ~op0 as op0 ^ -1. * gcc.c-torture/compile/pr91204.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@273629 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/optabs.c11
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr91204.c11
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8adea2d7b35..535636bb830 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/91204
+ * optabs.c (expand_unop): As fallback, expand ~op0 as op0 ^ -1.
+
2019-07-20 John David Anglin <danglin@gcc.gnu.org>
* config/pa/pa.h (hppa_profile_hook): Delete declaration.
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 4b39ff61193..06bcaab1f55 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -2972,6 +2972,17 @@ expand_unop (machine_mode mode, optab unoptab, rtx op0, rtx target,
return target;
}
+ /* Emit ~op0 as op0 ^ -1. */
+ if (unoptab == one_cmpl_optab
+ && (SCALAR_INT_MODE_P (mode) || GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
+ && optab_handler (xor_optab, mode) != CODE_FOR_nothing)
+ {
+ temp = expand_binop (mode, xor_optab, op0, CONSTM1_RTX (mode),
+ target, unsignedp, OPTAB_DIRECT);
+ if (temp)
+ return temp;
+ }
+
if (optab_to_code (unoptab) == NEG)
{
/* Try negating floating point values by flipping the sign bit. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index adefdb937ab..cd553db4b39 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2019-07-20 Jakub Jelinek <jakub@redhat.com>
+ PR target/91204
+ * gcc.c-torture/compile/pr91204.c: New test.
+
* c-c++-common/gomp/cancel-1.c: Adjust expected diagnostic wording.
* c-c++-common/gomp/clauses-1.c (foo, baz, bar): Add order(concurrent)
clause where allowed. Add combined constructs with loop with all
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr91204.c b/gcc/testsuite/gcc.c-torture/compile/pr91204.c
new file mode 100644
index 00000000000..dc267329eda
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr91204.c
@@ -0,0 +1,11 @@
+/* PR target/91204 */
+
+int a, b, c[64];
+
+void
+foo (void)
+{
+ int i;
+ for (i = 2; i < 64; i++)
+ c[i] &= b ^ c[i] ^ c[i - 2];
+}