From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27377 invoked by alias); 19 Jun 2011 15:15:11 -0000 Received: (qmail 27292 invoked by uid 22791); 19 Jun 2011 15:15:10 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_LR X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 19 Jun 2011 15:14:56 +0000 From: "oleg.endo@t-online.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49468] New: SH Target: inefficient integer abs code X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: oleg.endo@t-online.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sun, 19 Jun 2011 15:15:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01679.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49468 Summary: SH Target: inefficient integer abs code Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: oleg.endo@t-online.de The generated code for abs:SI and abs:DI is a bit inefficient: int abs (int i) { return (i < 0) ? -i : i; } mov r4,r1 shll r1 subc r1,r1 mov r1,r0 xor r4,r0 rts sub r1,r0 long long abs (long long i) { return (i < 0) ? -i : i; } mov r4,r3 shll r3 subc r3,r3 mov r5,r1 xor r3,r1 mov r3,r0 clrt xor r4,r0 subc r3,r1 rts subc r3,r0 There is a define_split in sh.md which is supposed to handle the special case for SH4 but it is not doing anything. The problem has been around since a couple of GCC 4.x versions. sh-elf-gcc -v Using built-in specs. COLLECT_GCC=sh-elf-gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sh-elf/4.7.0/lto-wrapper Target: sh-elf Configured with: ../gcc-trunk/configure --target=sh-elf --prefix=/usr/local --enable-languages=c,c++ --enable-multilib --disable-libssp --without-headers --disable-nls --disable-werror --enable-lto --with-newlib --with-gnu-as --with-gnu-ld --with-system-zlib : (reconfigured) ../gcc-trunk/configure --target=sh-elf --prefix=/usr/local --enable-languages=c,c++ --enable-multilib --disable-libssp --without-headers --disable-nls --disable-werror --enable-lto --with-newlib --with-gnu-as --with-gnu-ld --with-system-zlib : (reconfigured) ../gcc-trunk/configure --target=sh-elf --prefix=/usr/local --enable-languages=c,c++ --enable-multilib --disable-libssp --without-headers --disable-nls --disable-werror --enable-lto --with-newlib --with-gnu-as --with-gnu-ld --with-system-zlib : (reconfigured) ../gcc-trunk/configure --target=sh-elf --prefix=/usr/local --enable-multilib --disable-libssp --without-headers --disable-nls --disable-werror --enable-lto --with-newlib --with-gnu-as --with-gnu-ld --with-system-zlib target_alias=sh-elf CFLAGS=-Os CXXFLAGS=-Os --enable-languages=c,c++,lto --no-create --no-recursion Thread model: single gcc version 4.7.0 20110619 (experimental) (GCC)