================
@@ -2168,6 +2170,26 @@ void LoopInterchangeTransform::restructureLoops(
SE->forgetLoop(NewOuter);
}
+/// Update the metadata attached to the latch branches of the two loops. The
+/// loop metadata and the branch weights are dropped. Some attributes of the
+/// loop metadata may not hold after interchange (e.g.,
+/// llvm.loop.parallel_accesses of the inner loop doesn't imply that the loop
is
+/// parallel when it becomes the outer loop), and no followup attributes are
+/// defined for interchange.
+/// TODO: Preserve the branch weights by swapping them.
+void LoopInterchangeTransform::updateLatchMetadata() {
+ auto *OuterLoopLatchBI =
+ cast<CondBrInst>(OuterLoop->getLoopLatch()->getTerminator());
+ auto *InnerLoopLatchBI =
+ cast<CondBrInst>(InnerLoop->getLoopLatch()->getTerminator());
+
+ for (CondBrInst *BI : {OuterLoopLatchBI, InnerLoopLatchBI}) {
+ BI->setMetadata(LLVMContext::MD_loop, nullptr);
+ BI->setMetadata(LLVMContext::MD_prof, nullptr);
----------------
kasuga-fj wrote:
In this patch alone, I think they're still valid. However, for the same reason
as the loop metadata (see my reply on L2187), they would need to be swapped in
#235896, so I'd like to leave it to the follow-up as well.
As for the minor point, added a comment.
https://github.com/llvm/llvm-project/pull/235892
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits