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:17 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ 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] 21+ messages in thread

end of thread, other threads:[~2023-10-16 17:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-31531-4@http.gcc.gnu.org/bugzilla/>
2011-07-18 22:48 ` [Bug middle-end/31531] A microoptimization of isnegative of signed integer pinskia at gcc dot gnu.org
2012-02-12  4:36 ` pinskia at gcc dot gnu.org
2012-02-12  4:37 ` pinskia at gcc dot gnu.org
2012-02-12  4:39 ` pinskia at gcc dot gnu.org
2012-02-12 22:58 ` pinskia at gcc dot gnu.org
2012-02-13  0:44 ` pinskia at gcc dot gnu.org
2012-02-13  6:30 ` pinskia at gcc dot gnu.org
2012-02-13  7:47 ` pinskia at gcc dot gnu.org
2012-02-14  3:59 ` pinskia at gcc dot gnu.org
2014-10-31  4:02 ` pinskia at gcc dot gnu.org
2021-06-03  8:58 ` pinskia at gcc dot gnu.org
2021-11-20  7:23 ` pinskia at gcc dot gnu.org
2021-11-20  8:11 ` pinskia at gcc dot gnu.org
2021-11-21 14:37 ` pinskia at gcc dot gnu.org
2023-10-15 20:55 ` pinskia at gcc dot gnu.org
2023-10-16  2:34 ` pinskia at gcc dot gnu.org
2023-10-16 17:01 ` cvs-commit at gcc dot gnu.org
2023-10-16 17:03 ` pinskia at gcc dot gnu.org
2007-04-10 18:05 [Bug c/31531] New: A microoptimization of isnegative or greaterthan2millions 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).