X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave.korn@artimi.com>
To: <cygwin@cygwin.com>
References:  <20070121143731.GC25379@ns1.anodized.com> <009401c73d79$4cf91d40$a501a8c0@CAM.ARTIMI.COM>  <loom.20070122T085309-902@post.gmane.org>
Subject: RE: cygwin source question
Date: Mon, 22 Jan 2007 10:42:19 -0000
Message-ID: <00b401c73e11$fdc39d10$a501a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
Content-Type: text/plain; 	charset="US-ASCII"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 11
In-Reply-To:  <loom.20070122T085309-902@post.gmane.org>
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On 22 January 2007 08:19, Yitzchak Scott-Thoennes wrote:

> 
> Some people prefer (expr) ? 1 : 0, which looks a lot worse to me than
> !!(expr). 
> 

  Compiles to the exact same thing at -O0 and at -O2, as it happens...

/tmp $ gcc -x c -S -o - -

int foo (int argc)
{
  return (argc == 23) ? 1 : 0;
}

int bar (int argc)
{
  return !!(argc == 23);
}

        .file   ""
        .text
.globl _foo
        .def    _foo;   .scl    2;      .type   32;     .endef
_foo:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $23, 8(%ebp)
        sete    %al
        movzbl  %al, %eax
        popl    %ebp
        ret
.globl _bar
        .def    _bar;   .scl    2;      .type   32;     .endef
_bar:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $23, 8(%ebp)
        sete    %al
        movzbl  %al, %eax
        popl    %ebp
        ret
@_______. .
(       /"\
 ||--||(___)
 '"  '"'---'
/tmp $ gcc -O0 -x c -S -o - -

int foo (int argc)
{
  return (argc == 23) ? 1 : 0;
}

int bar (int argc)
{
  return !!(argc == 23);
}

        .file   ""
        .text
.globl _foo
        .def    _foo;   .scl    2;      .type   32;     .endef
_foo:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $23, 8(%ebp)
        sete    %al
        movzbl  %al, %eax
        popl    %ebp
        ret
.globl _bar
        .def    _bar;   .scl    2;      .type   32;     .endef
_bar:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $23, 8(%ebp)
        sete    %al
        movzbl  %al, %eax
        popl    %ebp
        ret
@_______. .
(       /"\
 ||--||(___)
 '"  '"'---'
/tmp $ gcc -O2 -x c -S -o - -

int foo (int argc)
{
  return (argc == 23) ? 1 : 0;
}

int bar (int argc)
{
  return !!(argc == 23);
}

        .file   ""
        .text
        .p2align 4,,15
.globl _foo
        .def    _foo;   .scl    2;      .type   32;     .endef
_foo:
        pushl   %ebp
        xorl    %eax, %eax
        movl    %esp, %ebp
        cmpl    $23, 8(%ebp)
        popl    %ebp
        sete    %al
        ret
        .p2align 4,,15
.globl _bar
        .def    _bar;   .scl    2;      .type   32;     .endef
_bar:
        pushl   %ebp
        xorl    %eax, %eax
        movl    %esp, %ebp
        cmpl    $23, 8(%ebp)
        popl    %ebp
        sete    %al
        ret
@_______. .
(       /"\
 ||--||(___)
 '"  '"'---'
/tmp $


  ... so no reason not to choose whichever you like the best.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

