diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -3561,6 +3561,7 @@ for (const TreePredicateCall &Call : Src->getPredicateCalls()) { const TreePredicateFn &Predicate = Call.Fn; + bool HasPredicateCode = false; if (Predicate.isAlwaysTrue()) continue; @@ -3569,6 +3570,11 @@ continue; } + if (Predicate.hasGISelPredicateCode()) { + HasPredicateCode = true; + InsnMatcher.addPredicate(Predicate); + } + // An address space check is needed in all contexts if there is one. if (Predicate.isLoad() || Predicate.isStore() || Predicate.isAtomic()) { if (const ListInit *AddrSpaces = Predicate.getAddressSpaces()) { @@ -3705,14 +3711,9 @@ continue; } } - - if (Predicate.hasGISelPredicateCode()) { - InsnMatcher.addPredicate(Predicate); - continue; - } - - return failedImport("Src pattern child has predicate (" + - explainPredicates(Src) + ")"); + if (!HasPredicateCode) + return failedImport("Src pattern child has predicate (" + + explainPredicates(Src) + ")"); } if (SrcGIEquivOrNull && SrcGIEquivOrNull->getValueAsBit("CheckMMOIsNonAtomic")) InsnMatcher.addPredicate("NotAtomic");