Match NewPassManager behavior: add option for interleaved loops in the
old pass manager, and use that instead of the flag used to disable loop unroll.
No changes in the defaults.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
How does this impact use of clang -fno-unroll-loops and clang -fno-loop-vectorize? I'm betting today, -fno-unroll-loops controls the DisableUnrollLoops value, and so people who disable both unrolling and vectorization will be surprised when interleaving now happens.
I think we want to set this to true in clang only when both unrolling and vectorization are enabled as a coarse approximation if the separate flag here, mostly because I think those most impacted will be those who disable one or the other and don't want this behavior in that case.
Is it correct to say that coupling this change with a clang change in:
lib/CodeGen/BackendUtil.cpp:546 PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
To add:
PMBuilder. LoopsInterleaved = CodeGenOpts.UnrollLoops;
AFAICT this is the only place this is set in clang.
Then defer when/if the separation is to ever happen to clang itself?
Have you already had an RFC regarding this change? If so, please add a link here. I bet there are a reasonable number of people who are dependent on vectorizer's interleave behavior is hooked up to the unroll flag. I support the direction as being the right thing to do, but we better give a good warning signal so that the affected people will scope the work. Do we already have a clang level interleave control flag? Else, those who are using unroll flag to control interleaving have to use -mllvm -interleave-loops= to get back to the original behavior......
Thanks a lot for the suggestion! Sent: http://lists.llvm.org/pipermail/llvm-dev/2019-April/131968.html
My intention was to not make any change visible to clang.
If clang currently sets the DisableUnrollLoops, and llvm will not use that for LoopVectorization, then have clang set LoopsInterleaved to the same value as the one used for unroll loops.
Adding a separate clang flag for interleaving can be a follow-up change.
Please let me know if this sound reasonable and if I misunderstood how/where clang is setting the flags.
You mean, clang setting EnableLoopInterleaving. If needed, we can make that change in clang first, i.e., before D61030 goes in, right? If so, there are no immediate surprises to clang users, I think.
Adding a separate clang flag for interleaving can be a follow-up change.
Please let me know if this sound reasonable and if I misunderstood how/where clang is setting the flags.
Sounds reasonable to me.
You mean, clang setting EnableLoopInterleaving.
Actually I meant DisableUnrollLoops in the PassManagerBuilder. It's currently always set to false, not based on a flag, and I found a single instance where it's value is changed in clang (see clang patch).
I'm happy to make whatever change needed to clang first, but I don't see what that change is. If you could point me to what I've missed, that would be great!
All I ask is to check whether -fno-unroll-loops and -funroll-loops clang flags affects what the LoopVectorize constructor sees in it's first incoming parameter. Should be easy enough to print that from the constructor to know for sure. If that's done or your confidence level is as high as that, that's all I need. If those flags affects what LoopVectorize gets, I don't want that behavior to change, and I believe that is also your intent.
I verified that the two unroll flags propagate to the option set in the PassManagerBuilder. This change + the clang change in D61142 should not make any visible change for clang users.
Cheers. Added some of the vectorizer oriented developers to the review. Hope they all like the terminology fix done here.
lib/Transforms/IPO/PassManagerBuilder.cpp | ||
---|---|---|
674 ↗ | (On Diff #196662) | I may not have understood the problem, but to keep the previous behaviour, souldn't this be: MPM.add(createLoopVectorizePass(DisableUnrollLoops || !LoopsInterleaved, !LoopVectorize)); |
lib/Transforms/IPO/PassManagerBuilder.cpp | ||
---|---|---|
674 ↗ | (On Diff #196662) | I think, the intent of the patch is to change that (but not for clang until next time around). http://lists.llvm.org/pipermail/llvm-dev/2019-April/131968.html |
lib/Transforms/IPO/PassManagerBuilder.cpp | ||
---|---|---|
674 ↗ | (On Diff #196662) | Per the clang sibling-patch (D61142), the added field is LoopsInterleaved = !DisableUnrollLoops. The new flag can be controlled in opt, vs DisableUnrollLoops could not. A separate clang change can add flags such as -floop-interleave, -fno-loop-interleave to control this flag separately from the -fno-unroll-loops. I am not planning to make this addition. |
lib/Transforms/IPO/PassManagerBuilder.cpp | ||
---|---|---|
674 ↗ | (On Diff #196662) | Ah, makes sense! Thanks! |