mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-28 23:17:10 +00:00
[NVPTX] Emit .pragma "nounroll" for loops marked with nounroll
Summary: CUDA driver can unroll loops when jit-compiling PTX. To prevent CUDA driver from unrolling a loop marked with llvm.loop.unroll.disable is not unrolled by CUDA driver, we need to emit .pragma "nounroll" at the header of that loop. This patch also extracts getting unroll metadata from loop ID metadata into a shared helper function. Test Plan: test/CodeGen/NVPTX/nounroll.ll Reviewers: eliben, meheff, jholewinski Reviewed By: jholewinski Subscribers: jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D7041 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227703 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -549,3 +549,26 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Given an llvm.loop loop id metadata node, returns the loop hint metadata
|
||||
/// node with the given name (for example, "llvm.loop.unroll.count"). If no
|
||||
/// such metadata node exists, then nullptr is returned.
|
||||
const MDNode *llvm::GetUnrollMetadata(const MDNode *LoopID, StringRef Name) {
|
||||
// First operand should refer to the loop id itself.
|
||||
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
|
||||
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
|
||||
|
||||
for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
|
||||
const MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
|
||||
if (!MD)
|
||||
continue;
|
||||
|
||||
const MDString *S = dyn_cast<MDString>(MD->getOperand(0));
|
||||
if (!S)
|
||||
continue;
|
||||
|
||||
if (Name.equals(S->getString()))
|
||||
return MD;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user