[llvm-bugs] [Bug 31892] New: Division-based loop induction variables not recognized

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 7 09:39:15 PST 2017


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

            Bug ID: 31892
           Summary: Division-based loop induction variables not recognized
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: justin.lebar at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I was surprised to see that LLVM does not get rid of the idiv in the following
code:

void foo(int);

void test(int n, int k) {
  if (k <= 0) return;
  for (int i = 0; i < n; i += k) {
    foo(i / k);
  }
}

https://godbolt.org/g/nqjfLq

Indeed, it doesn't even seem to recognize that the idiv is exact. 
https://ghostbin.com/paste/2hmtj

This is not a particularly uncommon idiom; might be worth handling better.

-- 
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/20170207/eaa413fc/attachment.html>


More information about the llvm-bugs mailing list