cdl-saarland / rv

RV: A Unified Region Vectorizer for LLVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IsSupportedReduction error output

mppf opened this issue · comments

The Chapel compiler is generating LLVM IR that, when optimized with RV, runs into the case here outputting to errs().

IsSupportedReduction(Loop & L, Reduction & red) {
// check that all users of the reduction are either (a) part of it or (b) outside the loop
for (auto * inst : red.elements) {
for (auto itUser : inst->users()) {
auto * userInst = dyn_cast<Instruction>(itUser);
if (!userInst) return false; // unsupported
if (L.contains(userInst->getParent()) &&
!red.elements.count(userInst)) {
errs() << "Unsupported user of reduction: "; Dump(*userInst);
return false;
}
}
}

Does this mean that there is something wrong with the LLVM IR being generated by the frontend (i.e. a correctness issue when optimized with RV)? Or is it a situation where RV figures out it cannot optimize this case and where extra debug output is present?

I observed this problem with a loop that had a loop carried dependency but that the frontend was hinting should be vectorized. I am working on getting the frontend not to hint vectorization in this case, but I'd still like to know the answer to the question.

I'll take this bit of README.md to answer my question:

Be aware that RV will exactly do as you annotated. Specifically, RV does not perform exhaustive legality checks nor is there cost modelling of any kind. You'll get what you ordered.

Meaning that there is a correctness issue.

There is an unsupported loop carried dependence in the IR.
RV only supports certain kinds of loop carried dependencies and bails otherwise, as happens here for a use of a reduction value inside the loop that is being vectorized.

This is related to: #43 (comment)