[PATCH] D104631: [LoopVersioning] Allow versionLoop to create plain branch inst when no runtime check is specified

Yueh-Ting Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 10 08:21:37 PST 2021


eopXD added a comment.

> IIUC you only need 3). Personally it seems like extending versionLoop to only do 3) makes the interface more complicated than it needs to be. Instead, would it be possible to extract the code to do 3) into a utility function that returns the conditional branch to select the loop? Then you could use that in LoopIdiomRecognize directly.

Hi @fhahn,

Sorry for the late reply.
I think I have made minimum change for `versionLoop` and only exposed utility functions (`getRuntimeCheckBB` and `getRuntimeCheckBI`) for use. 
The usage of these two functions are inside D104636 <https://reviews.llvm.org/D104636>.
Since @Whitney have accepted it I think we can land this and proceed to the child patches and give LoopNestIdiomRecognize a try?

  /// versionTopLoop - Create a fallback version the TopLoop
  void LoopIdiomRecognize::versionTopLoop() {
    const LoopAccessInfo LAI(TopLoop, SE, TLI, AA, DT, LI);
    LoopVersioning LV(LAI, LAI.getRuntimePointerChecking()->getChecks(), TopLoop,
                      LI, DT, SE);
  
    LV.versionLoopWithPlainRuntimeCheck();
  
    RuntimeCheckBB = LV.getRuntimeCheckBB();
    FallBackLoop = LV.getNonVersionedLoop();
  }



================
Comment at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:79
+  /// Returns the basic block that contains the runtime check BranchInst
+  BasicBlock *getRuntimeCheckBB() { return RuntimeCheckBB; }
+
----------------
fhahn wrote:
> dead code? (same for the other changes here)
It is dead code right now but will be used in D104636.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104631



More information about the llvm-commits mailing list