From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2908 invoked by alias); 1 Sep 2005 02:04:08 -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 2715 invoked by uid 48); 1 Sep 2005 02:03:48 -0000 Date: Thu, 01 Sep 2005 02:04:00 -0000 From: "pinskia at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050901020344.23669.pinskia@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug middle-end/23669] New: fold does convert (-a)/10 into a/-10. X-Bugzilla-Reason: CC X-SW-Source: 2005-09/txt/msg00019.txt.bz2 List-Id: Another idea from LLVM. The following two functions should be the same asm: int f(int a) { return (-a)/10; } int f1(int a) { return a/-10; } ---- We currently get on PPC: _f: lis r0,0x6666 neg r3,r3 ori r0,r0,26215 mulhw r0,r3,r0 srawi r3,r3,31 srawi r0,r0,2 subf r3,r3,r0 blr _f1: lis r0,0x6666 ori r0,r0,26215 mulhw r0,r3,r0 srawi r3,r3,31 srawi r0,r0,2 subf r3,r0,r3 blr As you can see f1 has one less instruction which should be better. -- Summary: fold does convert (-a)/10 into a/-10. Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P2 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org OtherBugsDependingO 19987 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23669