From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2731 invoked by alias); 9 Jul 2004 18:05:37 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2454 invoked by uid 9082); 9 Jul 2004 18:05:32 -0000 Date: Fri, 09 Jul 2004 18:05:00 -0000 From: "gcc-bugzilla at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20040709175338.16458.steinmtz@us.ibm.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug regression/16458] New: PowerPC - redundant compare X-Bugzilla-Reason: CC X-SW-Source: 2004-07/txt/msg00948.txt.bz2 List-Id: Description: A non-optimal compare sequence is illustrated. Two compares are being done, one signed and the other unsigned. One unsigned compare would suffice. Duplicate using gcc 3.5 and command line: gcc -O3 -m64 -c test.c Testcase: unsigned int a, b; int foo () { if (a == b) return 1; if (a > b) return 2; if (a < b) return 3; if (a != b) return 4; return 0; } Assembly: ld 9,.LC1@toc(2) li 3,1 ld 11,.LC0@toc(2) lwz 10,0(9) lwz 0,0(11) cmpw 7,0,10 - signed compare of a and b cmplw 6,0,10 - unsigned compare of a and b beqlr- 7 - (a == b uses signed compare) li 3,2 bgtlr- 6 - (a > b uses unsigned compare) li 3,4 bgelr- 6 - (a != b uses unsigned compare) li 3,3 blr -- Summary: PowerPC - redundant compare Product: gcc Version: 3.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P1 Component: regression AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: steinmtz at us dot ibm dot com CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm dot com GCC build triplet: powerpc64-linux GCC host triplet: powerpc64-linux GCC target triplet: powerpc64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16458