[llvm-bugs] [Bug 27899] New: failure to convert FP addition loop into a constant

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 26 15:24:43 PDT 2016


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

            Bug ID: 27899
           Summary: failure to convert FP addition loop into a constant
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

If we continue on the path from the realistic (bug 27881, bug 27894) to the
absurd, I think we end here. :)

float OneMeelion() {
  float sum = 0.0f;
  for (int i = 0; i < 1000; i++)
    sum += 1000.0f;

  return sum;
}

We don't need fast-math to know this answer.

$ ./clang -O2 OneMeelion.c -S -o -
...
    xorps    %xmm0, %xmm0
    movl    $1000, %eax             ## imm = 0x3E8
    movss    LCPI0_0(%rip), %xmm1    ## xmm1 = mem[0],zero,zero,zero
    .p2align    4, 0x90
LBB0_1:                                 ## %for.body
                                        ## =>This Inner Loop Header: Depth=1
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addss    %xmm1, %xmm0
    addl    $-10, %eax
    jne    LBB0_1


Surprisingly, this didn't vectorize!

That's because "-Rpass-analysis=loop-vectorize":
remark: loop not vectorized: cannot prove it is safe to reorder floating-point
operations

-- 
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/20160526/0a65a0d9/attachment.html>


More information about the llvm-bugs mailing list