LowerMatrixIntrinsics wasn't running yet running under the new pass manager, and this adds LowerMatrixIntrinsics to the pipeline. It's added early so that these matrix intrinsics, which are produced by Clang, to give other optimiser the opportunity to clean up / optimise this further.
Details
Diff Detail
Event Timeline
llvm/lib/Passes/PassBuilder.cpp | ||
---|---|---|
933 | I think we should keep this under the same enable-matrix flag like in the old pass manager for now and remove the flag for both when the pass only gets run on functions that contain matrix intrinsics. |
llvm/lib/Passes/PassBuilder.cpp | ||
---|---|---|
933 | Ah yeah, cheers, forgot about that! Will add that. |
clang/lib/CodeGen/BackendUtil.cpp | ||
---|---|---|
1381 ↗ | (On Diff #279538) | IIUC this references the LLVM option. Does this actually work? Shouldn't that use LangOpts.MatrixTypes, which is set when passing -fenable-matrix to Clang. |
clang/test/CodeGen/matrix-lowering-opt-levels.c | ||
8 | Might be good to add new-pm run-lines as well. | |
llvm/lib/Passes/PassBuilder.cpp | ||
933 | Is there reason this is run at a different position to the legacy pass manager? If not, I think we should run them at roughly the same location, to minimize differences between new and old PM. In the old pass manager, we run before the VectorizerStart callbacks. Here this would be around line 1102 I think. |
clang/lib/CodeGen/BackendUtil.cpp | ||
---|---|---|
1381 ↗ | (On Diff #279538) | It does actually :) But must indeed be a layering violation...will fix. |
clang/test/CodeGen/matrix-lowering-opt-levels.c | ||
8 | The many mysteries of the NPM..... Now looking I guess you mean adding -fexperimental-new-pass-manager (I was working with a build with the NPM enabled/built). | |
llvm/lib/Passes/PassBuilder.cpp | ||
933 | Since the intrinsics are generated by Clang I thought lowering them the earlier the better. And in the old PM, EarlyCSE was run after it, so that's why I put it right here just before EarlyCSE, but wouldn't mind moving it to where you suggested. |
clang/test/CodeGen/matrix-lowering-opt-levels.c | ||
---|---|---|
8 | adding lines with -fexperimental-new-pass-manager is what I mean. Not sure if that works with NPM enabled builds though. | |
llvm/lib/Passes/PassBuilder.cpp | ||
933 | Yes, EarlyCSE runs after LowerMatrixIntrinsics in addition, if EnableMatrix. I think it's not worth diverging in the new PM. If there's a better position, we should use it for both new PM/LegacyPM. |
LGTM, thanks! It would be good to also run EarlyCSE as mentioned inline.
llvm/lib/Passes/PassBuilder.cpp | ||
---|---|---|
1099 | We should probably also run EarlyCSE afterwards (if EnableMatrix is true), to keep things in sync with the legacy PM. |
Might be good to add new-pm run-lines as well.