[llvm-bugs] [Bug 25509] New: [LIR] Misses simple memset case

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 12 08:47:19 PST 2015


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

            Bug ID: 25509
           Summary: [LIR] Misses simple memset case
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: mcrosier at codeaurora.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

LLVM is unable to generate a memset from the below test:

void test(int *arr) {
  for (int i = 0; i < 1024; ++i) {
    arr[i] = 0;
    arr[i+1024] = 0;
  }
}

As of r252817 clang produces:
test:                                   // @test
// BB#0:                                // %entry
        mov      x8, xzr
        movi    v0.2d, #0000000000000000
.LBB0_1:                                // %vector.body
                                        // =>This Inner Loop Header: Depth=1
        add             x9, x0, x8
        add     x8, x8, #16             // =16
        str             q0, [x9]
        str     q0, [x9, #4096]
        cmp             x8, #1, lsl #12 // =4096
        b.ne    .LBB0_1
// BB#2:                                // %for.cond.cleanup
        ret

GCC is able to generate 2 memsets (one per arr access).  If I'm not mistaken
this can be transformed into a single memset (i.e., memset(arr, 0, 2048)).

-- 
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/20151112/ee8ac922/attachment.html>


More information about the llvm-bugs mailing list