Posted to tcl by aspect at Wed Sep 30 01:39:29 GMT 2015view raw
- with -Os, the unoptimised version compiles as:
- CompareVarKeys:
- .LFB82:
- pushq %r13 #
- pushq %r12 #
- pushq %rbp #
- pushq %rbx #
- pushq %rcx #
- movq 32(%rsi), %rbp # hPtr_10(D)->key.objPtr, objPtr2
- cmpq %rbp, %rdi # objPtr2, keyPtr
- jne .L107 #,
- .L111:
- movl $1, %r13d #, D.20762
- jmp .L108 #
- .L107:
- movq 8(%rdi), %r12 # MEM[(struct Tcl_Obj *)keyPtr_8(D)].bytes, p1
- movq %rdi, %rbx # keyPtr, keyPtr
- testq %r12, %r12 # p1
- jne .L109 #,
- call Tcl_GetString@PLT #
- movq %rax, %r12 #, p1
- .L109:
- movq 8(%rbp), %rsi # objPtr2_11->bytes, p2
- movl 16(%rbx), %ebx # MEM[(struct Tcl_Obj *)keyPtr_8(D)].length, l1
- testq %rsi, %rsi # p2
- jne .L110 #,
- movq %rbp, %rdi # objPtr2,
- call Tcl_GetString@PLT #
- movq %rax, %rsi #, p2
- .L110:
- xorl %r13d, %r13d # D.20762
- cmpl 16(%rbp), %ebx # objPtr2_11->length, l1
- jne .L108 #,
- movslq %ebx, %rdx # l1, D.20763
- movq %r12, %rdi # p1,
- call memcmp@PLT #
- testl %eax, %eax # tmp95
- je .L111 #,
- .L108:
- popq %rdx #
- movl %r13d, %eax # D.20762,
- popq %rbx #
- popq %rbp #
- popq %r12 #
- popq %r13 #
- ret
- Optimised version:
- CompareVarKeys:
- movq 32(%rsi), %rsi # hPtr_5(D)->key.objPtr, objPtr2
- cmpq %rsi, %rdi # objPtr2, keyPtr
- je .L113 #,
- jmp CompareDistinctVarKeys #
- .L113:
- movl $1, %eax #,
- ret
- CompareDistinctVarKeys:
- pushq %r12 #
- pushq %rbp #
- movq %rsi, %r12 # objPtr2, objPtr2
- pushq %rbx #
- movq 8(%rdi), %rbp # objPtr1_7(D)->bytes, p1
- movq %rdi, %rbx # objPtr1, objPtr1
- testq %rbp, %rbp # p1
- jne .L107 #,
- call Tcl_GetString@PLT #
- movq %rax, %rbp #, p1
- .L107:
- movq 8(%r12), %rsi # objPtr2_12(D)->bytes, p2
- movl 16(%rbx), %ebx # objPtr1_7(D)->length, l1
- testq %rsi, %rsi # p2
- jne .L108 #,
- movq %r12, %rdi # objPtr2,
- call Tcl_GetString@PLT #
- movq %rax, %rsi #, p2
- .L108:
- xorl %eax, %eax # D.20770
- cmpl 16(%r12), %ebx # objPtr2_12(D)->length, l1
- jne .L109 #,
- movslq %ebx, %rdx # l1, D.20771
- movq %rbp, %rdi # p1,
- call memcmp@PLT #
- testl %eax, %eax # tmp95
- sete %al #, D.20770
- movzbl %al, %eax # D.20770, D.20770
- .L109:
- popq %rbx #
- popq %rbp #
- popq %r12 #
- ret