This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][ARM][4.9 backport] Fix PR target/68648


Hi all,

This the 4.9 backport of https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00708.html.
The gcc change is the same, but the testcase is put into gcc.dg/torture rather than gcc.c-torture/execute.
This is because the testcase actually requires a -std=gnu99, and adding a dg-options in execute.exp doesn't seem
to work (it gets ignored). On GCC 5 we default to the required -std level already, so we don't need
the option there.

In gcc.dg/torture dg-options works and the testcase behaves as expected.
I'm committing this to the 4.9 branch and we can close this PR (I've already done the GCC 5 backport)

Thanks,
Kyrill

2016-01-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    PR target/68648
    * config/arm/arm.md (*andsi_iorsi3_notsi): Try to simplify
    the complement of operands[3] during splitting.

2016-01-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    PR target/68648
    * gcc.dg/torture/pr68648.c: New test.
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 3bb8aef36f7ed54faeeb05f4b2b9825d96162f54..138d17e8d7dec2c38c4daa531b46be3e0ce88cea 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -3331,8 +3331,22 @@ (define_insn_and_split "*andsi_iorsi3_notsi"
   "#"   ; "orr%?\\t%0, %1, %2\;bic%?\\t%0, %0, %3"
   "&& reload_completed"
   [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))
-   (set (match_dup 0) (and:SI (not:SI (match_dup 3)) (match_dup 0)))]
-  ""
+   (set (match_dup 0) (and:SI (match_dup 4) (match_dup 5)))]
+  {
+     /* If operands[3] is a constant make sure to fold the NOT into it
+	to avoid creating a NOT of a CONST_INT.  */
+    rtx not_rtx = simplify_gen_unary (NOT, SImode, operands[3], SImode);
+    if (CONST_INT_P (not_rtx))
+      {
+	operands[4] = operands[0];
+	operands[5] = not_rtx;
+      }
+    else
+      {
+	operands[5] = operands[0];
+	operands[4] = not_rtx;
+      }
+  }
   [(set_attr "length" "8")
    (set_attr "ce_count" "2")
    (set_attr "predicable" "yes")
diff --git a/gcc/testsuite/gcc.dg/torture/pr68648.c b/gcc/testsuite/gcc.dg/torture/pr68648.c
new file mode 100644
index 0000000000000000000000000000000000000000..762eb8243bd786f1232ecb3ad5d3f7773476c2ba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr68648.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+int __attribute__ ((noinline))
+foo (void)
+{
+  return 123;
+}
+
+int __attribute__ ((noinline))
+bar (void)
+{
+  int c = 1;
+  c |= 4294967295 ^ (foo () | 4073709551608);
+  return c;
+}
+
+int
+main ()
+{
+  if (bar () != 0x83fd4005)
+    __builtin_abort ();
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]