freetype-devel
[Top][All Lists]
Advanced

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

Re: [ft-devel] integer suffix abuse


From: Tom Bishop, Wenlin Institute
Subject: Re: [ft-devel] integer suffix abuse
Date: Wed, 24 Jun 2015 13:12:57 -0400

> On Jun 24, 2015, at 11:52 AM, Alexei Podtelezhnikov <address@hidden> wrote:
> 
> Hi All,
> 
> I think we abuse the suffix L in integer constants. I understand the
> desire to make sure that very common 0x10000L is 32-bit to represent a
> unit in 16.16 fixed-point representation. On modern 64-bit systems
> that actually becomes an unnecessary 64-bit constant. Perhaps the
> suffix was used with 16-bit systems in mind, but 0x10000 cannot fit
> into 16-bit integer and will always be 32-bit even on 16-bit systems.
> 
> Am I missing something?

Is your main concern that the executable code might be larger/slower than 
necessary, or that the source code is unnecessarily enlarged/cluttered by L 
suffixes?

I would have guessed that with a 64-bit compiler the resulting executable code 
would be the same with or without L. (The definitions of types like FT_Fixed 
and FT_Long would make more difference.) Surprisingly, changing all 0x10000L to 
0x10000 in FreetypeAmalgam.c really does produce a few different assembly 
language instructions (using Xcode). (See below for the diff.)

Best wishes,

Tom

diff test_L.u8 test_no_L.u8
2c2
< # Generated at 12:13:05 PM on Wednesday, June 24, 2015
---
> # Generated at 12:30:21 PM on Wednesday, June 24, 2015
39068,39070c39068
<       movl    %eax, %ecx
<       movl    $65536, %eax            ## imm = 0x10000
<       movl    %eax, %edx
---
>       movl    $65536, %ecx            ## imm = 0x10000
39073,39075c39071,39074
<       cmovneq %rdx, %rcx
<       movq    -144(%rbp), %rdx
<       movq    %rcx, (%rdx)
---
>       cmovnel %ecx, %eax
>       movslq  %eax, %rdx
>       movq    -144(%rbp), %rsi
>       movq    %rdx, (%rsi)
39077,39079c39076,39078
<       movq    -144(%rbp), %rcx
<       addq    $8, %rcx
<       movq    %rcx, -144(%rbp)
---
>       movq    -144(%rbp), %rdx
>       addq    $8, %rdx
>       movq    %rdx, -144(%rbp)
39109,39111c39108
<       movl    %eax, %ecx
<       movl    $65536, %eax            ## imm = 0x10000
<       movl    %eax, %edx
---
>       movl    $65536, %ecx            ## imm = 0x10000
39114,39116c39111,39114
<       cmovneq %rdx, %rcx
<       movq    -144(%rbp), %rdx
<       movq    %rcx, (%rdx)
---
>       cmovnel %ecx, %eax
>       movslq  %eax, %rdx
>       movq    -144(%rbp), %rsi
>       movq    %rdx, (%rsi)
39118,39120c39116,39118
<       movq    -144(%rbp), %rcx
<       addq    $8, %rcx
<       movq    %rcx, -144(%rbp)
---
>       movq    -144(%rbp), %rdx
>       addq    $8, %rdx
>       movq    %rdx, -144(%rbp)
39142,39144c39140
<       movl    %eax, %ecx
<       movl    $65536, %eax            ## imm = 0x10000
<       movl    %eax, %edx
---
>       movl    $65536, %ecx            ## imm = 0x10000
39147,39149c39143,39146
<       cmovneq %rdx, %rcx
<       movq    -144(%rbp), %rdx
<       movq    %rcx, (%rdx)
---
>       cmovnel %ecx, %eax
>       movslq  %eax, %rdx
>       movq    -144(%rbp), %rsi
>       movq    %rdx, (%rsi)
39151,39153c39148,39150
<       movq    -144(%rbp), %rcx
<       addq    $8, %rcx
<       movq    %rcx, -144(%rbp)
---
>       movq    -144(%rbp), %rdx
>       addq    $8, %rdx
>       movq    %rdx, -144(%rbp)
168324c168321
<       .loc    1 144104 30             ## FreeTypeAmalgam.c:144104:30
---
>       .loc    1 144104 29             ## FreeTypeAmalgam.c:144104:29
202116,202117c202113
<       movl    %ecx, %esi
<       movq    $-65536, %rdi           ## imm = 0xFFFFFFFFFFFF0000
---
>       movl    $4294901760, %edx       ## imm = 0xFFFF0000
202121,202122c202117,202119
<       cmovlq  %rdi, %rsi
<       movq    %rsi, -40(%rbp)
---
>       cmovll  %edx, %ecx
>       movslq  %ecx, %rax
>       movq    %rax, -40(%rbp)
240482c240479
<       .loc    1 75753 22              ## FreeTypeAmalgam.c:75753:22
---
>       .loc    1 75753 21              ## FreeTypeAmalgam.c:75753:21


Wenlin Institute, Inc. SPC (a Social Purpose Corporation)
文林研究所社会目的公司
Software for Learning Chinese
E-mail: address@hidden     Web: http://www.wenlin.com
Telephone: 1-877-4-WENLIN (1-877-493-6546)
☯






reply via email to

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