@@ -3007,13 +3007,12 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit,
3007
3007
// and "(MY_PAT $b, $a)" should not be allowed in the same pattern;
3008
3008
// neither should "(MY_PAT_1 $a, $b)" and "(MY_PAT_2 $a, $b)".
3009
3009
auto OperandId = std::make_pair (Operator, i);
3010
- auto PrevOp = ComplexPatternOperands.find (Child->getName ());
3011
- if (PrevOp != ComplexPatternOperands.end ()) {
3012
- if (PrevOp->getValue () != OperandId)
3013
- error (" All ComplexPattern operands must appear consistently: "
3014
- " in the same order in just one ComplexPattern instance." );
3015
- } else
3016
- ComplexPatternOperands[Child->getName ()] = OperandId;
3010
+ auto [PrevOp, Inserted] =
3011
+ ComplexPatternOperands.try_emplace (Child->getName (), OperandId);
3012
+ if (!Inserted && PrevOp->getValue () != OperandId) {
3013
+ error (" All ComplexPattern operands must appear consistently: "
3014
+ " in the same order in just one ComplexPattern instance." );
3015
+ }
3017
3016
}
3018
3017
}
3019
3018
@@ -3095,14 +3094,14 @@ bool TreePattern::InferAllTypes(
3095
3094
// If we have input named node types, propagate their types to the named
3096
3095
// values here.
3097
3096
if (InNamedTypes) {
3098
- if (!InNamedTypes->count (Entry.getKey ())) {
3097
+ auto InIter = InNamedTypes->find (Entry.getKey ());
3098
+ if (InIter == InNamedTypes->end ()) {
3099
3099
error (" Node '" + std::string (Entry.getKey ()) +
3100
3100
" ' in output pattern but not input pattern" );
3101
3101
return true ;
3102
3102
}
3103
3103
3104
- const SmallVectorImpl<TreePatternNode *> &InNodes =
3105
- InNamedTypes->find (Entry.getKey ())->second ;
3104
+ const SmallVectorImpl<TreePatternNode *> &InNodes = InIter->second ;
3106
3105
3107
3106
// The input types should be fully resolved by now.
3108
3107
for (TreePatternNode *Node : Nodes) {
@@ -3855,7 +3854,8 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
3855
3854
continue ;
3856
3855
}
3857
3856
3858
- if (!InstInputs.count (OpName)) {
3857
+ auto InIter = InstInputs.find (OpName);
3858
+ if (InIter == InstInputs.end ()) {
3859
3859
// If this is an operand with a DefaultOps set filled in, we can ignore
3860
3860
// this. When we codegen it, we will do so as always executed.
3861
3861
if (Op.Rec ->isSubClassOf (" OperandWithDefaultOps" )) {
@@ -3868,8 +3868,8 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
3868
3868
" does not appear in the instruction pattern" );
3869
3869
continue ;
3870
3870
}
3871
- TreePatternNodePtr InVal = InstInputs[OpName] ;
3872
- InstInputs.erase (OpName ); // It occurred, remove from map.
3871
+ TreePatternNodePtr InVal = InIter-> second ;
3872
+ InstInputs.erase (InIter ); // It occurred, remove from map.
3873
3873
3874
3874
if (InVal->isLeaf () && isa<DefInit>(InVal->getLeafValue ())) {
3875
3875
const Record *InRec = cast<DefInit>(InVal->getLeafValue ())->getDef ();
0 commit comments