Skip to content

Commit 014edb1

Browse files
skachkov-inteligcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: ed1920c
Process legalization of 64-bit moves on VC backend side
1 parent e939e90 commit 014edb1

File tree

3 files changed

+177
-177
lines changed

3 files changed

+177
-177
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXDeadVectorRemoval.cpp

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -448,21 +448,6 @@ void GenXDeadVectorRemoval::processRdRegion(Instruction *Inst, LiveBits LB)
448448
addToWorkList(InInst);
449449
}
450450

451-
static Constant *undefDeadConstElements(Constant *C, LiveBits LB) {
452-
if (isa<UndefValue>(C) || isa<ConstantAggregateZero>(C))
453-
return C;
454-
if (!C->getType()->isVectorTy()) {
455-
IGC_ASSERT(LB.getNumElements() == 1);
456-
return LB.get(0) ? C : UndefValue::get(C->getType());
457-
}
458-
SmallVector<Constant *, 8> NewElems;
459-
for (unsigned i = 0; i < LB.getNumElements(); ++i)
460-
NewElems.push_back(LB.get(i)
461-
? C->getAggregateElement(i)
462-
: UndefValue::get(C->getType()->getScalarType()));
463-
return ConstantVector::get(NewElems);
464-
}
465-
466451
/***********************************************************************
467452
* processWrRegion : process a wrregion instruction for element liveness
468453
*/
@@ -548,9 +533,23 @@ void GenXDeadVectorRemoval::processWrRegion(Instruction *Inst, LiveBits LB)
548533
addToWorkList(OldInInst);
549534
// If some constant values are not in use, set it to undef so ConstantLoader
550535
// can benefit from it.
551-
else if (auto OldInConst = dyn_cast<Constant>(OldInVal))
552-
Inst->setOperand(GenXIntrinsic::GenXRegion::OldValueOperandNum,
553-
undefDeadConstElements(OldInConst, OldInLB));
536+
else if (auto OldInConst = dyn_cast<Constant>(OldInVal)) {
537+
Constant *NewInConst = nullptr;
538+
if (isa<UndefValue>(OldInConst))
539+
NewInConst = UndefValue::get(OldInConst->getType());
540+
else if(isa<ConstantAggregateZero>(OldInConst))
541+
NewInConst = ConstantAggregateZero::get(OldInConst->getType());
542+
else {
543+
SmallVector<Constant *, 8> NewElems;
544+
for (unsigned i = 0; i < OldInLB.getNumElements(); ++i)
545+
NewElems.push_back(OldInLB.get(i) ?
546+
OldInConst->getAggregateElement(i) :
547+
UndefValue::get(OldInConst->getType()->getScalarType()));
548+
NewInConst = ConstantVector::get(NewElems);
549+
}
550+
IGC_ASSERT(NewInConst);
551+
Inst->setOperand(GenXIntrinsic::GenXRegion::OldValueOperandNum, NewInConst);
552+
}
554553
}
555554
if (UsedOldInput) {
556555
// We know that at least one element of the "old value" input is used,
@@ -564,20 +563,10 @@ void GenXDeadVectorRemoval::processWrRegion(Instruction *Inst, LiveBits LB)
564563
*/
565564
void GenXDeadVectorRemoval::processBitCast(Instruction *Inst, LiveBits LB)
566565
{
567-
LiveBits InLB;
568-
LiveBitsStorage ConstVecLBS;
569-
auto InVal = Inst->getOperand(0);
570-
if (auto InInst = dyn_cast<Instruction>(InVal))
571-
InLB = createLiveBits(InInst);
572-
else if (isa<Constant>(InVal)) {
573-
unsigned NumElems =
574-
isa<VectorType>(InVal->getType())
575-
? cast<VectorType>(InVal->getType())->getNumElements()
576-
: 1;
577-
ConstVecLBS.setNumElements(NumElems);
578-
InLB = LiveBits(&ConstVecLBS, NumElems);
579-
} else
566+
auto InInst = dyn_cast<Instruction>(Inst->getOperand(0));
567+
if (!InInst)
580568
return;
569+
LiveBits InLB = createLiveBits(InInst);
581570
bool Modified = false;
582571
if (InLB.getNumElements() == LB.getNumElements())
583572
Modified = InLB.orBits(LB);
@@ -600,12 +589,8 @@ void GenXDeadVectorRemoval::processBitCast(Instruction *Inst, LiveBits LB)
600589
Modified |= InLB.set(Idx);
601590
}
602591
}
603-
if (Modified) {
604-
if (auto InInst = dyn_cast<Instruction>(InVal))
605-
addToWorkList(InInst);
606-
else if (auto InConst = dyn_cast<Constant>(InVal))
607-
Inst->setOperand(0, undefDeadConstElements(InConst, InLB));
608-
}
592+
if (Modified)
593+
addToWorkList(InInst);
609594
}
610595

611596
/***********************************************************************

0 commit comments

Comments
 (0)