Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the fix! This sounds like we need a vectorization pre-condition to check that the input loop only has the supported types (e.g., no vector types). I think we should introduce that check before we go into the vectorizeLoopNest/vectorizeLoop methods, because if we bail out and we have already modified part of the input code, we may leave the IR inconsistent. Would you mind moving that check to the runOnOperation method? Thanks!
Yep, get your point. I instead moved the check to isVectorizableLoopBodyWithOpCond(), which seems most appropriate.
mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp | ||
---|---|---|
282 | Please also check operand types. Could be a vector_store storing some value defined outside of the loop. |
mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp | ||
---|---|---|
282 | Does not look like we can do this, fails a bunch of SuperVectorizer tests. I think what we have here is correct, because we only want to result type to be a valid element type. For example, in vectorize_1d.mlir, we want to vectorize this load into a vector.transfer_read. Its result type is f32, which is valid vector element type. But its first operand, a memref, is not a valid vector type. |
mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp | ||
---|---|---|
282 | You can do something similar to line 263 for memref type. But if you think the current check is enough, that's fine. |
mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp | ||
---|---|---|
282 | Thanks, yeah. This caught an issue a new case, where the operands have invalid type but the result is valid. For example, I added a test involving a vector.reduce, where the operand is an invalid type of vector, and the result is a valid type of float. I think it would be good to have a case where we have:
I can't think of a scenario. I can add any recommended tests if there are any. |
Please also check operand types. Could be a vector_store storing some value defined outside of the loop.