[llvm-bugs] [Bug 38706] New: Redundant register zeroing

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 26 01:33:59 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38706

            Bug ID: 38706
           Summary: Redundant register zeroing
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

int main(int argc, char **argv) {
    int sum = 0;
    int counter = 0;

    for(counter = 1; counter < argc; counter++) {
        char *aux = argv[counter];
        while(*aux != '\0') {
            aux++;
            sum++;
        }
    }

    printf("Sum = %d\n", sum);

}

Trunk -O3 -fno-unroll-loops:
main: # @main
  mov rax, rsi
  xor esi, esi
  cmp edi, 2
  jl .LBB0_6
  mov ecx, edi
  xor esi, esi <---- not needed
  mov edx, 1
.LBB0_2:
  mov rdi, qword ptr [rax + 8*rdx]
  cmp byte ptr [rdi], 0
  je .LBB0_5
  add rdi, 1

3.8.1:
main: # @main
  mov rax, rsi
  xor esi, esi
  mov ecx, 1
  cmp edi, 2
  jl .LBB0_5
.LBB0_1:
  mov rdx, qword ptr [rax + 8*rcx]
  cmp byte ptr [rdx], 0
  je .LBB0_4
  inc rdx

https://godbolt.org/z/veVclA

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180826/8b676978/attachment.html>


More information about the llvm-bugs mailing list