@@ -496,16 +496,17 @@ NVPTXTTIImpl::getInstructionCost(const User *U,
496
496
// be to return the number of asm instructions embedded in the asm
497
497
// string.
498
498
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
+ });
509
510
return InstCount * TargetTransformInfo::TCC_Basic;
510
511
}
511
512
0 commit comments