https://bugs.kde.org/show_bug.cgi?id=386945

--- Comment #17 from Aaron Sawdey <acsaw...@linux.vnet.ibm.com> ---
Julian,
 The analysis is ok. The code that follows on either branch looks for a zero
byte in the process of producing the final result. 

What happens after the subf./beq is that a cmpb with 0 is done to check that we
are not going past the end of the string:

        beq 0,.L19
.L13:
        li 7,0
        cmpb 8,9,10
        cmpb 7,9,7
        orc 8,7,8
        cntlzd 8,8
        addi 8,8,8
        rldcl 3,9,8,56
        rldcl 10,10,8,56
        subf 3,10,3
        b .L10
.L19:
        cmpb 9,9,3
        cmpdi 7,9,0
        bne 7,.L10

If the beq is not taken, the cmpb/cmpb/orc sequence produces a result that has
FF in the byte position of either the first difference, or the first zero byte.
Then this identified byte is extracted from both strings and subtracted to
produce the final result.

We only need to look for zero in one string because: if one has zero and the
other does not, this will be a difference. If both have a zero byte in the same
position then comparing either one with all zeros will make that zero byte the
one that is extracted and subtracted to produce the final result.

If the beq is taken, then r3 contains zero and used to see if there is a zero
byte in r9 (which must be equal to r10). If there is a zero byte, then the
strings are equal and r3 is the result.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to