[llvm-bugs] [Bug 44703] New: Some remainder checks on loop IV can be simplified by having another IV
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 29 02:35:12 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44703
Bug ID: 44703
Summary: Some remainder checks on loop IV can be simplified by
having another IV
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: lebedev.ri at gmail.com
CC: llvm-bugs at lists.llvm.org
void reinit();
void work(int p);
void entry(int width) {
for (int p = 0; p < 8; ++p) {
if (p % 3 == 2)
reinit();
work(p);
}
}
Depending on the loop (what is `work()`, is loop unrolled, etc),
this 'rem' operation can end up being measurably costly.
But this can be instead rewritten as
void reinit();
void work(int p);
void entry(int width) {
int u = 0;
for (int p = 0; p < 8; ++p, ++u) {
if (u == 2) {
reinit();
u = -1;
}
work(p);
}
}
.. at the cost of extra induction variable.
https://godbolt.org/z/EdiSHi
--
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/20200129/b28a08d0/attachment.html>
More information about the llvm-bugs
mailing list