This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/33716] New: gcc generates suboptimal code for long long shifts
- From: "felix-gcc at fefe dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Oct 2007 16:20:16 -0000
- Subject: [Bug rtl-optimization/33716] New: gcc generates suboptimal code for long long shifts
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider this function:
unsigned long long x(unsigned long long l) {
return l >> 4;
}
gcc will use the shrd instruction here, which is much slower than doing it "by
hand" on at least Athlon, Pentium 3, VIA C3. On Core 2 shrd appears to be
faster.
On my Athlon 64, I measured 350 cycles vs 441 for a loop of 100.
On my Core 2, I measured 672 cycles vs 624.
So, my suggestion is: if -march= is set to Pentium 3 or a non-Intel CPU, don't
use shrd and shrl.
My benchmark program is on http://dl.fefe.de/shrd.c
--
Summary: gcc generates suboptimal code for long long shifts
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: felix-gcc at fefe dot de
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33716