@@ -452,8 +452,6 @@ void X86FoldTablesEmitter::addEntryWithFlags(FoldTable &Table,
452452 " Override entry unexpectedly" );
453453 X86FoldTableEntry Result = X86FoldTableEntry (RegInst, MemInst);
454454 Record *RegRec = RegInst->TheDef ;
455- Record *MemRec = MemInst->TheDef ;
456-
457455 Result.NoReverse = S & TB_NO_REVERSE;
458456 Result.NoForward = S & TB_NO_FORWARD;
459457 Result.FoldLoad = S & TB_FOLDED_LOAD;
@@ -464,21 +462,6 @@ void X86FoldTablesEmitter::addEntryWithFlags(FoldTable &Table,
464462 return ;
465463 }
466464
467- // Only table0 entries should explicitly specify a load or store flag.
468- if (&Table == &Table0) {
469- unsigned MemInOpsNum = MemRec->getValueAsDag (" InOperandList" )->getNumArgs ();
470- unsigned RegInOpsNum = RegRec->getValueAsDag (" InOperandList" )->getNumArgs ();
471- // If the instruction writes to the folded operand, it will appear as an
472- // output in the register form instruction and as an input in the memory
473- // form instruction.
474- // If the instruction reads from the folded operand, it well appear as in
475- // input in both forms.
476- if (MemInOpsNum == RegInOpsNum)
477- Result.FoldLoad = true ;
478- else
479- Result.FoldStore = true ;
480- }
481-
482465 Record *RegOpRec = RegInst->Operands [FoldedIdx].Rec ;
483466 Record *MemOpRec = MemInst->Operands [FoldedIdx].Rec ;
484467
@@ -575,6 +558,11 @@ void X86FoldTablesEmitter::updateTables(const CodeGenInstruction *RegInst,
575558 return ;
576559 }
577560
561+ // Only table0 entries should explicitly specify a load or store flag.
562+ // If the instruction writes to the folded operand, it will appear as
563+ // an output in the register form instruction and as an input in the
564+ // memory form instruction. If the instruction reads from the folded
565+ // operand, it will appear as in input in both forms.
578566 if (MemInSize == RegInSize && MemOutSize == RegOutSize) {
579567 // Load-Folding cases.
580568 // If the i'th register form operand is a register and the i'th memory form
@@ -590,7 +578,8 @@ void X86FoldTablesEmitter::updateTables(const CodeGenInstruction *RegInst,
590578 switch (I) {
591579 case 0 :
592580 assert (!IsBroadcast && " BroadcastTable0 needs to be added" );
593- addEntryWithFlags (Table0, RegInst, MemInst, S, 0 , IsManual);
581+ addEntryWithFlags (Table0, RegInst, MemInst, S | TB_FOLDED_LOAD, 0 ,
582+ IsManual);
594583 return ;
595584 case 1 :
596585 IsBroadcast
@@ -628,7 +617,8 @@ void X86FoldTablesEmitter::updateTables(const CodeGenInstruction *RegInst,
628617 if (isRegisterOperand (RegOpRec) && isMemoryOperand (MemOpRec) &&
629618 getRegOperandSize (RegOpRec) == getMemOperandSize (MemOpRec)) {
630619 assert (!IsBroadcast && " Store can not be broadcast" );
631- addEntryWithFlags (Table0, RegInst, MemInst, S, 0 , IsManual);
620+ addEntryWithFlags (Table0, RegInst, MemInst, S | TB_FOLDED_STORE, 0 ,
621+ IsManual);
632622 }
633623 }
634624}
0 commit comments