After this function call, the LLVM IR would look like the following:
if (true) /* NonVersionedLoop */ else /* VersionedLoop */
Paths
| Differential D104631
[LoopVersioning] Allow versionLoop to create plain branch inst when no runtime check is specified ClosedPublic Authored by eopXD on Jun 21 2021, 3:41 AM.
Details Summary After this function call, the LLVM IR would look like the following: if (true) /* NonVersionedLoop */ else /* VersionedLoop */
Diff Detail
Event TimelineeopXD added a parent revision: D104620: [LoopVersioning] Add utility to fetch the runtime check basic block.Jun 21 2021, 3:42 AM Comment Actions User may need to create versioned loops of such structure to append more runtime checks conditions to the branch instruction. Comment Actions
Are you planning on sharing a follow-up that makes use of the new functionality? That would be helpful to review this and the earlier patch, to make sure the new API is a good fit. Also, it would be good to have a way to test this. Comment Actions The design seems weird here. eopXD added a child revision: D104636: [WIP][LoopIdiom] Teach LNIR to versioning loops and add runtime check.Jun 21 2021, 5:38 AM Comment Actions In terms of structuring of LoopVersioning, I think it would be great if the existing functionality could be refactored so that there is a set of helper functions that expose the functionality for re-use, rather than growing the existing LoopVersioning class. Comment Actions Hi @fhahn , Aside from adding helper functions, I think removing the assertion that "ensures RuntimeCheck is not a nullptr is necessary, Thank you for reviewing this patch. Herald added subscribers: frasercrmck, kerbowa, luismarques and 22 others. · View Herald TranscriptJun 26 2021, 2:15 AM eopXD removed a child revision: D104636: [WIP][LoopIdiom] Teach LNIR to versioning loops and add runtime check.Aug 3 2021, 7:53 AM eopXD added a child revision: D104636: [WIP][LoopIdiom] Teach LNIR to versioning loops and add runtime check.Aug 3 2021, 7:59 AM This revision is now accepted and ready to land.Aug 24 2021, 10:59 AM Comment Actions
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.
eopXD retitled this revision from [LoopVersioning] add function to create versioned loop with plain runtime check to [LoopVersioning] Allow versionLoop to create plain branch inst when no runtime check is specified.Aug 25 2021, 11:53 PM Comment Actions
Hi @fhahn, Sorry for the late reply. /// 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(); }
eopXD removed a child revision: D104636: [WIP][LoopIdiom] Teach LNIR to versioning loops and add runtime check.Dec 16 2021, 12:19 AM eopXD added a child revision: D104636: [WIP][LoopIdiom] Teach LNIR to versioning loops and add runtime check. This revision was landed with ongoing or failed builds.Dec 16 2021, 12:41 AM Closed by commit rGfbf6c8ac1589: [LoopVersioning] Allow versionLoop to create plain branch inst when no runtime… (authored by eopXD). · Explain Why This revision was automatically updated to reflect the committed changes. eopXD removed a child revision: D104636: [WIP][LoopIdiom] Teach LNIR to versioning loops and add runtime check.Dec 16 2021, 12:50 AM Comment Actions
FWIW I still think the interface should be adopted to make this more useable, rather than just adding on additional state that makes it even harder to make further changes. While the changes here are indeed a bit smaller than improving the interface, the additional state that needs maintained increases the complexity of the class even further, which has a cost down the road. I *think* the patch should only be committed once D104636 has also been accepted; at the moment there's nothing to test the new functionality.
Revision Contents
Diff 354658 llvm/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/AMDGPU/popcnt.ll
llvm/test/Transforms/LoopIdiom/ARM/ctlz.ll
llvm/test/Transforms/LoopIdiom/RISCV/popcnt.ll
llvm/test/Transforms/LoopIdiom/X86/arithmetic-right-shift-until-zero.ll
llvm/test/Transforms/LoopIdiom/X86/ctlz.ll
llvm/test/Transforms/LoopIdiom/X86/cttz.ll
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-bittest.ll
llvm/test/Transforms/LoopIdiom/X86/left-shift-until-zero.ll
llvm/test/Transforms/LoopIdiom/X86/logical-right-shift-until-zero-cost.ll
llvm/test/Transforms/LoopIdiom/X86/logical-right-shift-until-zero-debuginfo.ll
llvm/test/Transforms/LoopIdiom/X86/logical-right-shift-until-zero.ll
llvm/test/Transforms/LoopIdiom/X86/popcnt.ll
llvm/test/Transforms/LoopIdiom/X86/unordered-atomic-memcpy.ll
llvm/test/Transforms/LoopIdiom/basic-address-space.ll
llvm/test/Transforms/LoopIdiom/basic.ll
llvm/test/Transforms/LoopIdiom/crash.ll
llvm/test/Transforms/LoopIdiom/ctpop-multiple-users-crash.ll
llvm/test/Transforms/LoopIdiom/dbginfo-cost.ll
llvm/test/Transforms/LoopIdiom/debug-line.ll
llvm/test/Transforms/LoopIdiom/disable-options.ll
llvm/test/Transforms/LoopIdiom/expander-do-not-delete-reused-values.ll
llvm/test/Transforms/LoopIdiom/int_sideeffect.ll
llvm/test/Transforms/LoopIdiom/lir-heurs-multi-block-loop.ll
llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll
llvm/test/Transforms/LoopIdiom/memcpy-intrinsic-different-types.ll
llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll
llvm/test/Transforms/LoopIdiom/memcpy-vectors.ll
llvm/test/Transforms/LoopIdiom/memcpy.ll
llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll
llvm/test/Transforms/LoopIdiom/memset.ll
llvm/test/Transforms/LoopIdiom/memset_noidiom.ll
llvm/test/Transforms/LoopIdiom/non-canonical-loop.ll
llvm/test/Transforms/LoopIdiom/non-integral-pointers.ll
llvm/test/Transforms/LoopIdiom/nontemporal_store.ll
llvm/test/Transforms/LoopIdiom/phi-insertion.ll
llvm/test/Transforms/LoopIdiom/pr28196.ll
llvm/test/Transforms/LoopIdiom/pr33114.ll
llvm/test/Transforms/LoopIdiom/reuse-cast.ll
llvm/test/Transforms/LoopIdiom/scev-invalidation.ll
llvm/test/Transforms/LoopIdiom/scev-invalidation_topmostloop.ll
llvm/test/Transforms/LoopIdiom/struct-custom-dl.ll
llvm/test/Transforms/LoopIdiom/struct.ll
llvm/test/Transforms/LoopIdiom/struct_pattern.ll
llvm/test/Transforms/LoopIdiom/unordered-atomic-memcpy-noarch.ll
llvm/test/Transforms/LoopIdiom/unroll-custom-dl.ll
llvm/test/Transforms/LoopIdiom/unroll.ll
llvm/test/Transforms/LoopIdiom/unsafe.ll
llvm/test/Transforms/LoopIdiom/unwind.ll
|
clang-format not found in user’s local PATH; not linting file.