Author: Eugene Nalimov
Date: 09:12:16 09/29/05
Go up one level in this thread
On September 29, 2005 at 01:26:54, Dezhi Zhao wrote:
>The compiler is not very aware of 64 bit operands. It should be not difficult to
>calculate the size of a simple structure and utilize one of the many registers
>instead of using the stack.
Yes, it is not very difficult, but we decided to spend resources optimizing
legal C/C++ programs, not the cases where language standard explicitly says
"behavior is undefined".
Program still does what programmer intended (it does not give you access
violation, nor it formats your hard drive), though code is suboptimal...
Thanks,
Eugene
:-)
>; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.26
>
>include listing.inc
>
>INCLUDELIB OLDNAMES
>
>PUBLIC wmain
>; Function compile flags: /Ogtpy
>; File c:\documents and settings\administrator\my documents\visual studio
>2005\projects\x64\x64\x64.cpp
>; COMDAT wmain
>_TEXT SEGMENT
>argc$ = 8
>q$ = 16
>argv$ = 16
>wmain PROC ; COMDAT
>
>; 9 : union
>; 10 : {
>; 11 : unsigned __int64 qw;
>; 12 : struct
>; 13 : {
>; 14 : unsigned lo32;
>; 15 : unsigned hi32;
>; 16 : };
>; 17 : } q, i;
>; 18 :
>; 19 : q.lo32 = argc;
>; 20 : q.hi32 = (unsigned) argv;
>; 21 :
>; 22 : i.qw = (unsigned __int64) argv | (unsigned __int64) argc << 32;
>; 23 :
>; 24 : return q.qw == i.qw;
>
> xor eax, eax
> movsxd r8, ecx
> mov DWORD PTR q$[rsp], ecx
> shl r8, 32 ; 00000020H
> mov DWORD PTR q$[rsp+4], edx
> or r8, rdx
> cmp QWORD PTR q$[rsp], r8
> sete al
>
>; 25 : }
>
> ret 0
>wmain ENDP
>_TEXT ENDS
>END
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.