[llvm-bugs] [Bug 38699] New: wrong code with -disable-licm-promotion -enable-loop-distribute

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 25 01:30:30 PDT 2018


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

            Bug ID: 38699
           Summary: wrong code with -disable-licm-promotion
                    -enable-loop-distribute
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: paulsson at linux.vnet.ibm.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20767
  --> https://bugs.llvm.org/attachment.cgi?id=20767&action=edit
reduced testcase

Thanks to (for the) nice output of opt-viewer with the optimization remarks, I
tried the loop-distribute pass on a benchmark and got a huge speedup as
vectorization occurred (30%)  :-)

I then enabled this in csmith testing and found a wrong code bug which I
reduced to:

a, b, c, d, e;
main() {
  for (; b > -8; --b) {
    c = 0;
    for (; c != -14; c--) {
      if (b)
        break;
      --d;
    }
  }
  for (; e < 5; e++)
    a = c;
  printf("checksum = %X\n", a);
}

gcc -O1 -march=z10 -o a.out -w
gcc -O0 -march=z13 -o a.out -w
gcc -O1 -march=z13 -o a.out -w
clang -O0 -march=z10 -o a.out -w
clang -O0 -march=z13 -o a.out -w
clang -O3 -march=z10 -o a.out -w
clang -O3 -march=z13 -o a.out -w
clang -O3 -march=z13 -o a.out -w -mllvm -disable-licm-promotion -mllvm
-enable-loop-distribute

checksum = 0
checksum = 0
checksum = 0
checksum = 0
checksum = 0
checksum = 0
checksum = 0
checksum = 0
checksum = FFFFFFF2

-- 
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/20180825/ab901b9f/attachment.html>


More information about the llvm-bugs mailing list