[PATCH] D101142: [SimplifyCFG/JumpThreading] Do not simplify empty blocks with unconditional branches if this causes loop metadata confusion.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 18 12:34:23 PDT 2021


Meinersbur added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:1090
+    MDNode *PredMD = PredTI ? PredTI->getMetadata(LoopMDKind) : nullptr;
+    if (LoopMD != PredMD && BBIsLatch && IsLoopLatch(PredBB))
+      return false;
----------------
jeroen.dobbelaere wrote:
> Is (LoopMD != PredMD) a sufficient rule ?
> 
> Assume you have two nested loops with both a 'loop unroll 4' annotation. Can we get in a situation where both latches would be merged ? If so, is it valid then to still merge the latches ?
> 
The idea was that if the loops have the same properties, then they will still have the same properties after merging. That itself might be problematic since changing the LoopMD (e.g. LoopVectorize sets a `isvectorized` property when unable to vectorize) would apply to both loops.

However, also conside LoopMD are `distinct` and therefore different loop should have different MDNodes. This is not strictly enforced (e.g. Inliner or LoopUnroll duplicate entire loops), so it can happen for different loops to have the same LoopMD.
 
I can make the condition stricter by comparing the header blocks they branch to. 

Is there still interest in this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101142



More information about the llvm-commits mailing list