all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: Paul Eggert <eggert@cs.ucla.edu>, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r114450: * dispnew.c (clear_glyph_row, copy_row_except_pointers):
Date: Tue, 24 Sep 2013 04:43:26 -0700	[thread overview]
Message-ID: <52417ADE.70007@dancol.org> (raw)
In-Reply-To: <E1VOMrf-0001CU-O0@vcs.savannah.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

On 9/24/13 12:16 AM, Paul Eggert wrote:
> ------------------------------------------------------------
> revno: 114450
> revision-id: eggert@cs.ucla.edu-20130924071638-9k6809ka6hbocr2n
> parent: dmantipov@yandex.ru-20130924064320-9o1cx41btsnt1voo
> committer: Paul Eggert <eggert@cs.ucla.edu>
> 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.

int
with_signed (int arg)
{
    return arg/64;
}


unsigned
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

       reply	other threads:[~2013-09-24 11:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1VOMrf-0001CU-O0@vcs.savannah.gnu.org>
2013-09-24 11:43 ` Daniel Colascione [this message]
2013-09-24 15:26   ` [Emacs-diffs] trunk r114450: * dispnew.c (clear_glyph_row, copy_row_except_pointers): Paul Eggert
2013-09-24 12:19 ` Dmitry Antipov
2013-09-24 15:45   ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52417ADE.70007@dancol.org \
    --to=dancol@dancol.org \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.