From 60934f9cf4eec9feef395961c9dda139fa325845 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 11 Nov 2004 08:40:43 +0000 Subject: [PATCH] re PR target/16458 (PowerPC - redundant compare) .: 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 | 7 +++++++ gcc/config/rs6000/rs6000.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/ppc-compare-1.c | 16 ++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/ppc-compare-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8064f7f7f2c..195080d25de 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-11-11 Nathan Sidwell + + 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 * config/mips/linux.h (LINUX_TARGET_OS_CPP_BUILTINS): Define @@ -398,6 +404,7 @@ them static. * expr.h: Remove the corresponding prototypes. +>>>>>>> 2.6266 2004-11-08 Richard Earnshaw * arm.c (arm_handle_notshared_attribute): Wrap declaration and use diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 947ae2030e1..02b37fe078e 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8f6d5fd465b..814b05b8e20 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-11-11 Nathan Sidwell + + PR target/16458 + * gcc.dg/ppc-compare-1.c: New. + 2004-11-10 Joseph S. Myers * 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 index 00000000000..07aee48a576 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ppc-compare-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target powerpc64-*-* } } */ +/* { dg-options "-m64 -O2" } */ + +/* { dg-final { scan-assembler-not "cmpw" } } */ + +/* Origin:Pete Steinmetz */ + +/* 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; +} -- 2.30.2