public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31531]  New: A microoptimization of isnegative or greaterthan2millions.
@ 2007-04-10 18:05 JCPiza at gmail dot com
  2007-04-10 18:14 ` [Bug c/31531] " JCPiza at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: JCPiza at gmail dot com @ 2007-04-10 18:05 UTC (permalink / raw)
  To: gcc-bugs

/* Given X an unsigned of 32 bits, and Y a bool. Try to translate optimizing
*
* Y = X >  2147483647;   to   Y = ((signed)X) < 0;
* Y = X >= 2147483648;   to   Y = ((signed)X) < 0;
*
* [ Another optimization is to Y = (X >> 31) ]
*
* The opposite (ELSE):
*
* Y = X <= 2147483647;   to   Y = ((signed)X) >= 0;
* Y = X <  2147483648;   to   Y = ((signed)X) >= 0;
*
* [ Another optimization is to Y = ((~X) >> 31) ]
*
* 2147483647=0x7FFFFFFF   2147483648=0x80000000
*
* The unsigned comparison is become to signed comparison.
*
* by J.C. Pizarro */

# gcc version 4.1.3 20070326 (prerelease)
Full test of isnegative is PASSED.

notl    %eax
shrl    $31, %eax
xorl    $1, %eax

IS WORSE THAN

shrl $31, %eax

---------------------

xorl    %eax, %eax
cmpl    $0, 4(%esp)
sets    %al

IS WORSE THAN

movl    4(%esp), %eax
shrl    $31, %eax

------------------------------------------------------------------------------

Full info with src code and tarball is in
http://gcc.gnu.org/ml/gcc/2007-04/msg00317.html

I'm sorry, i did want to say 2 billions, not 2 millions.

J.C. Pizarro


-- 
           Summary: A microoptimization of isnegative or
                    greaterthan2millions.
           Product: gcc
           Version: 4.1.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: JCPiza at gmail dot com


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


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

end of thread, other threads:[~2007-04-15  5:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-10 18:05 [Bug c/31531] New: A microoptimization of isnegative or greaterthan2millions JCPiza at gmail dot com
2007-04-10 18:14 ` [Bug c/31531] " JCPiza at gmail dot com
2007-04-10 18:17 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu dot org
2007-04-10 18:20 ` pinskia at gcc dot gnu dot org
2007-04-15  5:43 ` pinskia at gcc dot gnu dot org

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).