[PATCH] D104631: [LoopVersioning] add function to create versioned loop with plain runtime check

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 11:12:22 PDT 2021


fhahn added a comment.

In D104631#2842314 <https://reviews.llvm.org/D104631#2842314>, @eopXD wrote:

> Hi @fhahn ,
>
> Aside from adding helper functions, I think removing the assertion that "ensures `RuntimeCheck` is not a `nullptr` is necessary,
> since in my use-case, the loop provided to `LoopVersioning` doesn't require any `MemRuntimeCheck` and `SCEVRuntimeCheck` but wants to clone the loop and setup a branch instruction for them.
> Other than that I kept the interface and logic of `versionLoop` the same.

Right, currently `versionLoop` roughly does the following things: 1) create memory runtime checks (if requested), 2) generate SCEV predicate checks (if requested) and 3) clone the loop and 4) branch to the right version depending on the generated runtime checks.

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.



================
Comment at: llvm/include/llvm/Transforms/Utils/LoopVersioning.h:79
+  /// Returns the basic block that contains the runtime check BranchInst
+  BasicBlock *getRuntimeCheckBB() { return RuntimeCheckBB; }
+
----------------
dead code? (same for the other changes here)


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