[llvm-bugs] [Bug 35016] New: suboptimal loop codegen?

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 20 15:36:52 PDT 2017


            Bug ID: 35016
           Summary: suboptimal loop codegen?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: trass3r at gmail.com
                CC: llvm-bugs at lists.llvm.org

#include <stdint.h>
uint8_t data[32] = { 1,2,3,4 };
int main(int argc, const char* argv[])
        int sum = 0;
        for (int i=0; i < argc; ++i)
#if 0
                sum += ((uint32_t*)data)[2 + i];
                sum += *(uint32_t*)&data[8 + i * 4];
        return sum;


$ clang -c -Oz
main: # @main
  movsxd rcx, edi
  xor edx, edx
  push 8
  pop rsi
  xor eax, eax
  jmp .LBB0_1
.LBB0_3: # in Loop: Header=BB0_1 Depth=1
  movsxd rsi, esi
  add eax, dword ptr [rsi + data]
  inc rdx
  add esi, 4
.LBB0_1: # =>This Inner Loop Header: Depth=1
  cmp rdx, rcx
  jl .LBB0_3

$ g++ -c -Os
  xor edx, edx
  xor eax, eax
  cmp edi, edx
  jle .L1
  add eax, DWORD PTR data[8+rdx*4]
  inc rdx
  jmp .L3
  .byte 1
  .byte 2
  .byte 3
  .byte 4
  .zero 28

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/20171020/bd10bea2/attachment-0001.html>

More information about the llvm-bugs mailing list