From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32148 invoked by alias); 11 Jun 2008 22:53:11 -0000 Received: (qmail 32065 invoked by uid 48); 11 Jun 2008 22:52:28 -0000 Date: Wed, 11 Jun 2008 22:53:00 -0000 Subject: [Bug target/36503] New: x86 can use x >> -y for x >> 32-y X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "astrange at ithinksw dot com" 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: 2008-06/txt/msg00697.txt.bz2 > gcc -v Using built-in specs. Target: i386-apple-darwin9.2.2 Configured with: ../gcc/configure --prefix=/usr/local/gcc44 --enable-threads=posix --with-arch=core2 --with-tune=core2 --with-gmp=/sw --with-mpfr=/sw --disable-nls --disable-bootstrap --enable-checking=yes,rtl --enable-languages=c,c++,objc Thread model: posix gcc version 4.4.0 20080611 (experimental) (GCC) gcc compiles int shift32(int i, int n) { return i >> (32 - n); } to _shift32: subl $12, %esp movl $32, %ecx subl 20(%esp), %ecx movl 16(%esp), %eax sarl %cl, %eax addl $12, %esp ret Since all 286-and-up CPUs only use the low 5 bits of ecx when shifting, this can be: _shift32: movl 8(%esp), %ecx movl 4(%esp), %eax negl %ecx sarl %cl, %eax ret This is very common in bitstream readers, where it's used to read the top N bits from a word. ffmpeg already has an inline asm to do it, which I'd like to get rid of. I'd guess this applies to some other architectures; it probably works on x86-64, but doesn't on PPC. -- Summary: x86 can use x >> -y for x >> 32-y Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: astrange at ithinksw dot com GCC target triplet: i?86-*-* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36503