[Issue 6829] Unsigned rotate standard function in Phobos

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 13 00:32:44 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=6829


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com


--- Comment #28 from Walter Bright <bugzilla at digitalmars.com> 2013-07-13 00:32:38 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> 
> > What's the pattern that DMD recognizes for rotate instructions?
> 
> Walter offers this example of recognizable rotation:

Ack, the example is bad. This one generates rol/ror:

-----------
void test(int shift)
{
    uint a = 7;
    uint r;
    r = (a >> shift) | (a << (int.sizeof * 8 - shift));
    assert(r == 0x8000_0003);
    r = (r << shift) | (r >> (int.sizeof * 8 - shift));
    assert(r == 7);
}
-----------
compiling with -O:

_D3foo4testFiZv comdat
        assume  CS:_D3foo4testFiZv
L0:             push    EAX
                mov     EDX,7
                mov     ECX,EAX
                push    EAX
                ror     EDX,CL
                cmp     EDX,080000003h
                push    EBX
                mov     4[ESP],EDX
                je      L22
                mov     EAX,6
                call    near ptr _D3foo8__assertFiZv
L22:            mov     EBX,4[ESP]
                mov     ECX,8[ESP]
                rol     EBX,CL
                cmp     EBX,7
                je      L3B
                mov     EAX,8
                call    near ptr _D3foo8__assertFiZv
L3B:            pop     EBX
                add     ESP,8
                ret

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list