re PR target/16458 (PowerPC - redundant compare)
authorNathan Sidwell <nathan@gcc.gnu.org>
Thu, 11 Nov 2004 08:40:43 +0000 (08:40 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 11 Nov 2004 08:40:43 +0000 (08:40 +0000)
.: PR target/16458
* config/rs6000/rs6000.c (rs6000_generate_compare): Generate an
unsigned equality compare when we know the operands are unsigned.
testsuite:
PR target/16458
* gcc.dg/ppc-compare-1.c: New.

From-SVN: r90475

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ppc-compare-1.c [new file with mode: 0644]

index 8064f7f..195080d 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-11  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR target/16458
+       * config/rs6000/rs6000.c (rs6000_generate_compare): Generate an
+       unsigned equality compare when we know the operands are unsigned.
+
 2004-11-10  Peter S. Mazinger  <ps.m@gmx.net>
 
        * config/mips/linux.h (LINUX_TARGET_OS_CPP_BUILTINS): Define
        them static.
        * expr.h: Remove the corresponding prototypes.
 
+>>>>>>> 2.6266
 2004-11-08  Richard Earnshaw  <rearnsha@arm.com>
 
        * arm.c (arm_handle_notshared_attribute): Wrap declaration and use
index 947ae20..02b37fe 100644 (file)
@@ -10910,6 +10910,16 @@ rs6000_generate_compare (enum rtx_code code)
   else if (code == GTU || code == LTU
           || code == GEU || code == LEU)
     comp_mode = CCUNSmode;
+  else if ((code == EQ || code == NE)
+          && GET_CODE (rs6000_compare_op0) == SUBREG
+          && GET_CODE (rs6000_compare_op1) == SUBREG
+          && SUBREG_PROMOTED_UNSIGNED_P (rs6000_compare_op0)
+          && SUBREG_PROMOTED_UNSIGNED_P (rs6000_compare_op1))
+    /* These are unsigned values, perhaps there will be a later
+       ordering compare that can be shared with this one.
+       Unfortunately we cannot detect the signedness of the operands
+       for non-subregs.  */
+    comp_mode = CCUNSmode;
   else
     comp_mode = CCmode;
 
index 8f6d5fd..814b05b 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-11  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR target/16458
+       * gcc.dg/ppc-compare-1.c: New.
+
 2004-11-10  Joseph S. Myers  <joseph@codesourcery.com>
 
        * objc.dg/desig-init-2.m: New test.
diff --git a/gcc/testsuite/gcc.dg/ppc-compare-1.c b/gcc/testsuite/gcc.dg/ppc-compare-1.c
new file mode 100644 (file)
index 0000000..07aee48
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile { target powerpc64-*-* } } */
+/* { dg-options "-m64 -O2" } */
+
+/* { dg-final { scan-assembler-not "cmpw" } } */
+
+/* Origin:Pete Steinmetz <steinmtz@us.ibm.com> */
+
+/* PR 16458: Extraneous compare.  */
+
+int foo (unsigned a, unsigned b)
+{
+  if (a == b) return 1;
+  if (a > b)  return 2;
+  if (a < b)  return 3;
+  return 0;
+}