]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
final.c (final_scan_insn): Handle all comparison codes in non-jump and cmove insn.
authorAndreas Schwab <schwab@linux-m68k.org>
Mon, 5 Nov 2012 21:11:04 +0000 (21:11 +0000)
committerAndreas Schwab <schwab@gcc.gnu.org>
Mon, 5 Nov 2012 21:11:04 +0000 (21:11 +0000)
* gcc/final.c (final_scan_insn) [HAVE_cc0]: Handle all comparison
codes in non-jump and cmove insn.

* gcc/testsuite/gcc.dg/torture/fp-compare.c: New testcase.

From-SVN: r193187

gcc/ChangeLog
gcc/final.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/fp-compare.c [new file with mode: 0644]

index 0d20017906e3a0f2f91c28292718c8560c5bbba1..d0ba9426b2a80ecdc07719b01afdcca25e23e4fa 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-05  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * final.c (final_scan_insn) [HAVE_cc0]: Handle all comparison
+       codes in non-jump and cmove insn.
+
 2012-11-05  Uros Bizjak  <ubizjak@gmail.com>
            Vladimir Yakovlev  <vladimir.b.yakovlev@intel.com>
 
index f69963d63350defe0a945d690791d61f3e336a60..fc10dd6d5a69f155bc51be544a9106cc18988247 100644 (file)
@@ -1,7 +1,7 @@
 /* Convert RTL to assembler code and output it, for GNU compiler.
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
    1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -2689,36 +2689,19 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
                else_rtx = const0_rtx;
              }
 
-           switch (GET_CODE (cond_rtx))
+           if (COMPARISON_P (cond_rtx)
+               && XEXP (cond_rtx, 0) == cc0_rtx)
              {
-             case GTU:
-             case GT:
-             case LTU:
-             case LT:
-             case GEU:
-             case GE:
-             case LEU:
-             case LE:
-             case EQ:
-             case NE:
-               {
-                 int result;
-                 if (XEXP (cond_rtx, 0) != cc0_rtx)
-                   break;
-                 result = alter_cond (cond_rtx);
-                 if (result == 1)
-                   validate_change (insn, &SET_SRC (set), then_rtx, 0);
-                 else if (result == -1)
-                   validate_change (insn, &SET_SRC (set), else_rtx, 0);
-                 else if (result == 2)
-                   INSN_CODE (insn) = -1;
-                 if (SET_DEST (set) == SET_SRC (set))
-                   delete_insn (insn);
-               }
-               break;
-
-             default:
-               break;
+               int result;
+               result = alter_cond (cond_rtx);
+               if (result == 1)
+                 validate_change (insn, &SET_SRC (set), then_rtx, 0);
+               else if (result == -1)
+                 validate_change (insn, &SET_SRC (set), else_rtx, 0);
+               else if (result == 2)
+                 INSN_CODE (insn) = -1;
+               if (SET_DEST (set) == SET_SRC (set))
+                 delete_insn (insn);
              }
          }
 
index 4d6a7dcc42c76f5dc077a99bb9b0ad5d77005a7d..af92ce4c7f58b689ff2c8b5d30be401346756429 100644 (file)
@@ -1,3 +1,7 @@
+2012-11-05  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * gcc.dg/torture/fp-compare.c: New testcase.
+
 2012-11-05  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/const-1.c: Update.
diff --git a/gcc/testsuite/gcc.dg/torture/fp-compare.c b/gcc/testsuite/gcc.dg/torture/fp-compare.c
new file mode 100644 (file)
index 0000000..0d51dfd
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* Check that find_scan_insn properly handles swapped FP comparisons.  */
+static double x;
+static int exit_code;
+
+void __attribute__ ((noinline))
+check_int (int a, int b)
+{
+  exit_code += (a != b);
+}
+
+int
+main (void)
+{
+  x = 0.0;
+  asm ("" : "+m" (x));
+  check_int (__builtin_isgreater (x, 1.0), 0);
+  check_int (__builtin_isgreaterequal (x, 1.0), 0);
+  check_int (__builtin_isless (x, 1.0), 1);
+  check_int (__builtin_islessequal (x, 1.0), 1);
+  check_int (__builtin_islessgreater (x, 1.0), 1);
+  return exit_code;
+}