[llvm-bugs] [Bug 24442] New: Another cse pass may be needed after LSR to clean up redundency introduced by SCEV expansion

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 12 14:25:49 PDT 2015


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

            Bug ID: 24442
           Summary: Another cse pass may be needed after LSR to clean up
                    redundency introduced by SCEV expansion
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: wmi at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

For the testcase 1.c below:

int a[1000];

int foo(int x, int y) {
  int i, total = 0;
  int m = (x < y) ? x : y;   // smin(x, y)
  for (i = 0; i < m; i++) {
    total += a[i];
  }
  return total;
}

~/workarea/llvm-r243653/build/bin/clang -O2 -S 1.c -o bad.s

In bad.s, we see that the smin is computed 5 times.

Loop iteration number is computed in SCEV form and expanded several times
separately by loop vectorization, loop unrolling and loop strength reduction
passes. The expansions introduces repeated computation, which however cannot be
removed because no late cse pass exists to cleanup those redundencies.

I try to add an instcombine pass and an early-cse pass after LSR, then smin is
computed 2 time in the generated good.s. It should be reduced to 1 but not,
because of another bug: https://llvm.org/bugs/show_bug.cgi?id=24441

-- 
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/20150812/fc2fa0a1/attachment.html>


More information about the llvm-bugs mailing list