[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] trunk r114450: * dispnew.c (clear_glyph_row, copy_row_

From: Daniel Colascione
Subject: Re: [Emacs-diffs] trunk r114450: * dispnew.c (clear_glyph_row, copy_row_except_pointers):
Date: Tue, 24 Sep 2013 04:43:26 -0700
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

On 9/24/13 12:16 AM, Paul Eggert wrote:
> ------------------------------------------------------------
> revno: 114450
> revision-id: address@hidden
> parent: address@hidden
> committer: Paul Eggert <address@hidden>
> branch nick: trunk
> timestamp: Tue 2013-09-24 00:16:38 -0700
> message:
>   * dispnew.c (clear_glyph_row, copy_row_except_pointers):
>   Prefer signed to unsigned integers where either will do.

Why? Signed integers have undefined overflow behavior and sometimes
result in less efficient code. If anything, we should prefer unsigned
integer types.

with_signed (int arg)
    return arg/64;

with_unsigned (unsigned arg)
    return arg/64;

$ gcc-mp-4.7 -O2 -march=core2 foo.c
$ gdb a.out
Reading symbols for shared libraries ... done
(gdb) disassemble with_signed
Dump of assembler code for function with_signed:
0x0000000100000f40 <with_signed+0>:     lea    0x3f(%rdi),%eax
0x0000000100000f43 <with_signed+3>:     test   %edi,%edi
0x0000000100000f45 <with_signed+5>:     cmovns %edi,%eax
0x0000000100000f48 <with_signed+8>:     sar    $0x6,%eax
0x0000000100000f4b <with_signed+11>:    retq
0x0000000100000f4c <with_signed+12>:    nopl   0x0(%rax)
End of assembler dump.
(gdb) disassemble with_unsigned
Dump of assembler code for function with_unsigned:
0x0000000100000f50 <with_unsigned+0>:   mov    %edi,%eax
0x0000000100000f52 <with_unsigned+2>:   shr    $0x6,%eax
0x0000000100000f55 <with_unsigned+5>:   retq
End of assembler dump.

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]