ummmm.. you were saying???

8:58:44pm  orb(19): cat bs3.c
#include <stdio.h>

int main(void)
 int toshiftornottoshift = 0x8000;

 printf("%d\n", toshiftornottoshift);

8:58:48pm  orb(20): cc -S -O2 -o bs3.s bs3.c
8:58:53pm  orb(21): cat bs3.s
       .file   "bs3.c"
       .section        .rodata.str1.1,"aMS",@progbits,1
       .string "%d\n"
       .p2align 4,,15
.globl main
       .type   main, @function
       subq    $8, %rsp
*      this doesn't look like the compiler generates a shift to me.
       movl    $32768, %esi
       movl    $.LC0, %edi
       xorl    %eax, %eax
       call    printf
       xorl    %eax, %eax
       addq    $8, %rsp
       .size   main, .-main
       .section        .eh_frame,"a",@progbits
       .long   .LECIE1-.LSCIE1
       .long   0x0
       .byte   0x1
       .string "zR"
       .uleb128 0x1
       .sleb128 -8
       .byte   0x10
       .uleb128 0x1
       .byte   0x3
       .byte   0xc
       .uleb128 0x7
       .uleb128 0x8
       .byte   0x90
       .uleb128 0x1
       .align 8
       .long   .LEFDE1-.LASFDE1
       .long   .LASFDE1-.Lframe1
       .long   .LFB3
       .long   .LFE3-.LFB3
       .uleb128 0x0
       .byte   0x4
       .long   .LCFI0-.LFB3
       .byte   0xe
       .uleb128 0x10
       .align 8
       .ident  "GCC: (GNU) 4.2.1 20070719  [FreeBSD]" wrote:
Jim Bryant <> wrote:

what kind of idiot defines a constant assignment for a 32k buffer as a 15 bit left shift of 1?

clever, yes.  but in production, stupid.

a constant should be just that, a constant, and thus require no computation at runtime.

Er, did you bother to look at the generated code before spouting off?
Most compilers, even as far back as K&R 1st edition, will compute
constant expressions like that at compile time.

_______________________________________________ mailing list
To unsubscribe, send any mail to ""

Reply via email to