[PATCH] D75240: Add a pass that specializes parallel loops for easier unrolling and vectorization

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 06:26:00 PST 2020


ftynse added inline comments.


================
Comment at: mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopPreparationForVectorization.cpp:1
+//===- ParallelLoopPreparationForVectorization.cpp - loop.parallel splitting =//
+//
----------------
(bikeshed) could we find a shorter name? ParallelLoopSpecialization?


================
Comment at: mlir/lib/Dialect/LoopOps/Transforms/ParallelLoopPreparationForVectorization.cpp:36
+    auto constantIndex =
+        dyn_cast_or_null<ConstantIndexOp>(minOp.getOperand(0).getDefiningOp());
+    if (!constantIndex)
----------------
This assumes the first operand of the map appears in the results of the map unmodified. While the "if" introduced below will make sure nothing bad happens if it does not, there may be cases where the generated code is dead. For example

```
%0 = affine.min affine_map<(d0)->(-d0,-1024)>(%c10)
loop.parallel (%i) = (%c0) to (%0)
```

will never have the upper bound of 10. I'd at least add a check that the operand indeed appears unmodified.

Another thing is canonicalization. If you canonicalize before this pass, constants should be folded into the affine map so you'll never have a constant index operand to affine apply. You could look into normalizing affine maps with operands and then just check if some _results_ are constant affine expressions. This is fine for a follow-up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75240/new/

https://reviews.llvm.org/D75240





More information about the llvm-commits mailing list