Skip to content

Commit 0f09da8

Browse files
committed
address comments
1 parent 985ab04 commit 0f09da8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,10 @@ MemoryEffects NVPTXAAResult::getMemoryEffects(const CallBase *Call,
132132
return MemoryEffects::unknown();
133133

134134
// Memory clobbers prevent optimization.
135-
if (!(Constraint.Type & InlineAsm::ConstraintPrefix::isClobber))
136-
continue;
137-
for (const std::string &Code : Constraint.Codes)
138-
if (Code == "{memory}")
139-
return MemoryEffects::unknown();
135+
if ((Constraint.Type & InlineAsm::ConstraintPrefix::isClobber) &&
136+
any_of(Constraint.Codes,
137+
[](const auto &Code) { return Code == "{memory}"; }))
138+
return MemoryEffects::unknown();
140139
}
141140
return MemoryEffects::none();
142141
}

llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,16 +496,17 @@ NVPTXTTIImpl::getInstructionCost(const User *U,
496496
// be to return the number of asm instructions embedded in the asm
497497
// string.
498498
auto &AsmStr = IA->getAsmString();
499-
SmallVector<StringRef, 4> AsmPieces;
500-
SplitString(AsmStr, AsmPieces, ";\n");
501-
502-
const unsigned InstCount = count_if(AsmPieces, [](StringRef AsmInst) {
503-
AsmInst = AsmInst.trim();
504-
// This is pretty course but does a reasonably good job of identifying
505-
// things that look like instructions, possibly with a predicate ("@").
506-
return !AsmInst.empty() && (AsmInst[0] == '@' || isAlpha(AsmInst[0]) ||
507-
AsmInst.find(".pragma") != StringRef::npos);
508-
});
499+
const unsigned InstCount =
500+
count_if(split(AsmStr, ';'), [](StringRef AsmInst) {
501+
// Trim off scopes denoted by '{' and '}' as these can be ignored
502+
AsmInst = AsmInst.trim().ltrim("{} \t\n\v\f\r");
503+
// This is pretty coarse but does a reasonably good job of
504+
// identifying things that look like instructions, possibly with a
505+
// predicate ("@").
506+
return !AsmInst.empty() &&
507+
(AsmInst[0] == '@' || isAlpha(AsmInst[0]) ||
508+
AsmInst.find(".pragma") != StringRef::npos);
509+
});
509510
return InstCount * TargetTransformInfo::TCC_Basic;
510511
}
511512

0 commit comments

Comments
 (0)