Fix PR target/63209.
authordavidxl <davidxl@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Sep 2014 20:10:25 +0000 (20:10 +0000)
committerdavidxl <davidxl@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Sep 2014 20:10:25 +0000 (20:10 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215136 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/arm/arm.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr63209.c [new file with mode: 0644]

index 3aaeb0d..6e532f8 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-10  Xinliang David Li  <davidxl@google.com>
+
+       PR target/63209
+       * config/arm/arm.md (movcond_addsi): Handle case where source
+       and target operands are the same.
+
 2014-09-10  David Malcolm  <dmalcolm@redhat.com>
 
        * final.c (this_is_asm_operands): Strengthen this variable from
index 5323574..e691562 100644 (file)
     enum machine_mode mode = SELECT_CC_MODE (GET_CODE (operands[5]),
                                             operands[3], operands[4]);
     enum rtx_code rc = GET_CODE (operands[5]);
-
     operands[6] = gen_rtx_REG (mode, CC_REGNUM);
     gcc_assert (!(mode == CCFPmode || mode == CCFPEmode));
-    rc = reverse_condition (rc);
+    if (REGNO (operands[2]) != REGNO (operands[0]))
+      rc = reverse_condition (rc);
+    else 
+      {
+       rtx tmp = operands[1];
+       operands[1] = operands[2];
+       operands[2] = tmp;
+      }
 
     operands[6] = gen_rtx_fmt_ee (rc, VOIDmode, operands[6], const0_rtx);
   }
index c9dfcb1..197297a 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-10  Xinliang David Li  <davidxl@google.com>
+
+       PR target/63209
+       * gcc.c-torture/execute/pr63209.c: New test.
+
 2014-09-10  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.target/i386/i386.exp: Only run vect-args.c tests
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr63209.c b/gcc/testsuite/gcc.c-torture/execute/pr63209.c
new file mode 100644 (file)
index 0000000..9bcb587
--- /dev/null
@@ -0,0 +1,27 @@
+static int Sub(int a, int b) {
+  return  b -a;
+}
+
+static unsigned Select(unsigned a, unsigned b, unsigned c) {
+  const int pa_minus_pb =
+      Sub((a >>  8) & 0xff, (b >>  8) & 0xff) + 
+      Sub((a >>  0) & 0xff, (b >>  0) & 0xff); 
+  return (pa_minus_pb <= 0) ? a : b;
+}
+
+__attribute__((noinline)) unsigned Predictor(unsigned left, const unsigned* const top) {
+  const unsigned pred = Select(top[1], left, top[0]);
+  return pred;
+}
+
+int main(void) {
+  const unsigned top[2] = {0xff7a7a7a, 0xff7a7a7a};
+  const unsigned left = 0xff7b7b7b;
+  const unsigned pred = Predictor(left, top /*+ 1*/);
+  if (pred == left)
+    return 0;
+  return 1;
+}
+
+
+