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



--- Comment #2 from Don <clugd...@yahoo.com.au> 2012-05-16 12:17:27 PDT ---
Marginally reduced (this is what the early optimizer passes turn this into):

int solve(int n) {
    int a = n ? (n>=1u) : 1;
    return a ? a : 0;
}

void main() {
    assert(solve(1) ==  1);
}

It looks as after common subexpression elimination of a, the branch address
from the >= is out by 1. The generated code is:

        push    EAX
        cmp    dword ptr -4[EBP],0
        je    L1C
        mov    ECX,1
        cmp    dword ptr -4[EBP],1
        jae    L1F
        mov    ECX,0
        jmp short    L1F <--- wrong address
L1C:        xor    ECX,ECX
        inc    ECX
L1F:        je    L25        <---- shouldn't jump here
        mov    EAX,ECX    <---- should jump here instead
        jmp short    L27
L25:        xor    EAX,EAX
L27:        mov    ESP,EBP

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

Reply via email to