[Issue 15629] [REG] wrong code with "-O -inline" but correct with "-O"
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jan 30 07:39:30 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15629
--- Comment #2 from Ivan Kazmenko <gassa at mail.ru> ---
Turned out that array b is also not necessary.
A bit less code (testmodule2.d):
-----
import std.math;
import std.stdio;
void main ()
{
int [] a = [3];
int value = abs (a[0]);
if (a[0] != 3)
{
writeln (value, " ", a);
assert (false);
}
}
-----
Disassembly:
-----
__Dmain PROC NEAR
; COMDEF __Dmain
sub esp, 36 ; 0000 _ 83. EC, 24
mov eax, 3 ; 0003 _ B8, 00000003
mov ecx, 1 ; 0008 _ B9, 00000001
mov dword ptr [esp+0CH], ebx ; 000D _ 89. 5C 24, 0C
mov dword ptr [esp+10H], esi ; 0011 _ 89. 74 24, 10
mov dword ptr [esp+18H], eax ; 0015 _ 89. 44 24, 18
mov dword ptr [esp+4H], ecx ; 0019 _ 89. 4C 24, 04
mov dword ptr [esp], offset FLAT:_D11TypeInfo_Ai6__initZ; 001D _
C7. 04 24, 00000000(segrel)
call __d_arrayliteralTX ; 0024 _ E8,
00000000(rel)
mov edx, eax ; 0029 _ 89. C2
mov eax, dword ptr [esp+18H] ; 002B _ 8B. 44 24, 18
mov dword ptr [esp+20H], edx ; 002F _ 89. 54 24, 20
mov ebx, dword ptr [esp+20H] ; 0033 _ 8B. 5C 24, 20
mov ecx, dword ptr [esp+14H] ; 0037 _ 8B. 4C 24, 14
mov dword ptr [edx], eax ; 003B _ 89. 02
mov esi, dword ptr [ebx] ; 003D _ 8B. 33
mov eax, esi ; 003F _ 89. F0
sar eax, 31 ; 0041 _ C1. F8, 1F
xor esi, eax ; 0044 _ 33. F0
sub esi, eax ; 0046 _ 2B. F0
mov dword ptr [esp+1CH], 1 ; 0048 _ C7. 44 24, 1C,
00000001
cmp ecx, 3 ; 0050 _ 83. F9, 03
jz ?_0056 ; 0053 _ 74, 24
push esi ; 0055 _ 56
mov edx, offset FLAT:?_0001 ; 0056 _ BA,
00000000(segrel)
mov ebx, 1 ; 005B _ BB, 00000001
push edx ; 0060 _ 52
push ebx ; 0061 _ 53
push dword ptr [esp+2CH] ; 0062 _ FF. 74 24, 2C
push dword ptr [esp+2CH] ; 0066 _ FF. 74 24, 2C
call _D3std5stdio21__T7writelnTiTAyaTAiZ7writelnFNfiAyaAiZv; 006A _
E8, 00000000(rel)
mov eax, 11 ; 006F _ B8, 0000000B
call _D11testmodule28__assertFiZv ; 0074 _ E8,
00000000(rel)
?_0056: mov ebx, dword ptr [esp+0CH] ; 0079 _ 8B. 5C 24, 0C
mov esi, dword ptr [esp+10H] ; 007D _ 8B. 74 24, 10
add esp, 36 ; 0081 _ 83. C4, 24
xor eax, eax ; 0084 _ 31. C0
ret ; 0086 _ C3
__Dmain ENDP
-----
Now the lines supposed to carry the "3" seem to be
-----
mov eax, 3 ; 0003 _ B8, 00000003
mov dword ptr [esp+18H], eax ; 0015 _ 89. 44 24, 18
mov eax, dword ptr [esp+18H] ; 002B _ 8B. 44 24, 18
mov dword ptr [edx], eax ; 003B _ 89. 02
-----
and then for some reason
-----
mov ecx, dword ptr [esp+14H] ; 0037 _ 8B. 4C 24, 14
cmp ecx, 3 ; 0050 _ 83. F9, 03
jz ?_0056 ; 0053 _ 74, 24
-----
--
More information about the Digitalmars-d-bugs
mailing list