@@ -615,10 +615,17 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) {
615615                           op.getQualCppClassName ()));
616616
617617  //  If the operand's name is set, set to that variable.
618-   auto  name = tree.getSymbol ();
618+   int  index = -1 ;
619+   auto  name = SymbolInfoMap::getValuePackName (tree.getSymbol (), &index).str ();
619620  if  (!name.empty ())
620621    os << formatv (" {0} = {1};\n "  , name, castedName);
621622
623+   if  (index != -1 ) {
624+     emitMatchCheck (opName,
625+       formatv (" (resultNumber{0} == 1)"  , depth),
626+       formatv (" \" {0} does not come from result number {1} type\" "  , castedName, index));
627+   }
628+ 
622629  for  (int  i = 0 , opArgIdx = 0 , e = tree.getNumArgs (), nextOperand = 0 ; i != e;
623630       ++i, ++opArgIdx) {
624631    auto  opArg = op.getArg (opArgIdx);
@@ -662,6 +669,10 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) {
662669          " auto *{0} = " 
663670          " (*{1}.getODSOperands({2}).begin()).getDefiningOp();\n "  ,
664671          argName, castedName, nextOperand);
672+         os.indent () << formatv (
673+           " [[maybe_unused]] auto resultNumber{0} = " 
674+           " ::llvm::dyn_cast<::mlir::OpResult>((*{1}.getODSOperands({2}).begin())).getResultNumber();\n "  ,
675+           depth + 1 , castedName, nextOperand);
665676      //  Null check of operand's definingOp
666677      emitMatchCheck (
667678          castedName, /* matchStr=*/  argName,
0 commit comments