re PR target/51408 (Miscompilation in arm.md:*minmax_arithsi)
authorKazu Hirata <kazu@codesourcery.com>
Mon, 5 Dec 2011 16:11:35 +0000 (16:11 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Mon, 5 Dec 2011 16:11:35 +0000 (16:11 +0000)
gcc/
PR target/51408
* config/arm/arm.md (*minmax_arithsi): Always require the else
clause in the MINUS case.

gcc/testsuite/
PR target/51408
* gcc.dg/pr51408.c: New.

From-SVN: r182014

gcc/ChangeLog
gcc/config/arm/arm.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr51408.c [new file with mode: 0644]

index 34d55bb0caef4c268398b3584c71aec1ef0a3a49..9e3bce6cc2e1bf708019719ceeb04052d053062d 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-05  Kazu Hirata  <kazu@codesourcery.com>
+
+       PR target/51408
+       * config/arm/arm.md (*minmax_arithsi): Always require the else
+       clause in the MINUS case.
+
 2011-12-05  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/50904
index 8ec9b2288bba6c9398fed06ae09e08bb1e4f8d7d..6493a791a4a20c1118a608a8c3977ad7dd385a0f 100644 (file)
     bool need_else;
 
     if (which_alternative != 0 || operands[3] != const0_rtx
-        || (code != PLUS && code != MINUS && code != IOR && code != XOR))
+        || (code != PLUS && code != IOR && code != XOR))
       need_else = true;
     else
       need_else = false;
index dcc8226acdd5f0884764c11db3de9917efc8dbd3..c8556570130d11263fca4e7e5e97814a917dc224 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-05  Kazu Hirata  <kazu@codesourcery.com>
+
+       PR target/51408
+       * gcc.dg/pr51408.c: New.
+
 2011-12-05  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/dc6.C: New.
diff --git a/gcc/testsuite/gcc.dg/pr51408.c b/gcc/testsuite/gcc.dg/pr51408.c
new file mode 100644 (file)
index 0000000..2cc5cf9
--- /dev/null
@@ -0,0 +1,22 @@
+/* This testcase used to fail because of a bug in 
+   arm.md:*minmax_arithsi.  */
+
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+extern void abort (void);
+
+int __attribute__((noinline))
+foo (int a, int b)
+{
+  int max = (b > 0) ? b : 0;
+  return max - a;
+}
+
+int
+main (void)
+{
+  if (foo (3, -1) != -3)
+    abort ();
+  return 0;
+}