public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/36473]  New: Generate bit test (bt) instructions
@ 2008-06-09  9:54 ubizjak at gmail dot com
  2008-06-09 11:40 ` [Bug target/36473] " ubizjak at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2008-06-09  9:54 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1805 bytes --]

According to Intel Technology Journal [1], page 270, bt instruction runs 20%
faster on Core2 Duo than equivalent generic code.

---Qoute from p.270---
The bit test instruction bt was introduced in the i386™
processor. In some implementations, including the Intel
NetBurst® micro-architecture, the instruction has a high
latency. The Intel Core micro-architecture executes bt in
a single cycle, when the bit base operand is a register.
Therefore, the Intel C++/Fortran compiler uses the bt
instruction to implement a common bit test idiom when
optimizing for the Intel Core micro-architecture. The
optimized code runs about 20% faster than the generic
version on an Intel Core 2 Duo processor. Both of these
versions are shown below:

C source code
  int x, n;
  ...
  if (x & (1 << n)) ...

Generic code generation
  ; edx contains x, ecx contains n.
  mov eax, 1
  shl eax, cl
  test edx, eax
  je taken

Intel Core micro-architecture code generation
  ; edx contains x, eax contains n.
  bt edx, eax
  jae taken
---/Quote---

I have a patch in testing that implements suggested optimization for
TARGET_USE_BT (including core2) targets.

[1] Inside the Intel® 10.1 Compilers: New Threadizer and New
Vectorizer for Intel® Core™2 Processors, Intel Technology Journal, Vol. 11,
Issue 4, November 15, 2007,
http://download.intel.com/technology/itj/2007/v11i4/1-inside/1-Inside_the_Intel_Compilers.pdf


-- 
           Summary: Generate bit test (bt) instructions
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ubizjak at gmail dot com
GCC target triplet: x86


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36473


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-13  8:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-09  9:54 [Bug target/36473] New: Generate bit test (bt) instructions ubizjak at gmail dot com
2008-06-09 11:40 ` [Bug target/36473] " ubizjak at gmail dot com
2008-06-09 11:41 ` ubizjak at gmail dot com
2008-06-10 10:30 ` uros at gcc dot gnu dot org
2008-07-13  8:44 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).