Skip to content

Commit

Permalink
Combine Set and Extract in PreLegalizerCombiner
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinay-anubola committed Sep 19, 2024
1 parent 46f23e1 commit 9f14742
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions llvm/lib/Target/AIE/AIE2PreLegalizerCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class AIE2PreLegalizerCombinerImpl : public Combiner {

bool tryToCombineVectorShiftsByZero(MachineInstr &MI) const;

bool tryToCombineSetExtract(MachineInstr &MI) const;

bool tryToCombineIntrinsic(MachineInstr &MI) const;

private:
Expand Down Expand Up @@ -136,13 +138,35 @@ bool AIE2PreLegalizerCombinerImpl::tryToCombineVectorShiftsByZero(
return true;
}

bool AIE2PreLegalizerCombinerImpl::tryToCombineSetExtract(
MachineInstr &MI) const {
const Register DstReg = MI.getOperand(0).getReg();
MachineInstr *ExtOp = MRI.getUniqueVRegDef(MI.getOperand(2).getReg());

assert(ExtOp && "Expected SSA.");
if (ExtOp->getOpcode() != AIE2::G_INTRINSIC ||
cast<GIntrinsic>(*ExtOp).getIntrinsicID() !=
Intrinsic::aie2_extract_I128_I512)
return false;

MachineIRBuilder MIRBuilder(MI);
MIRBuilder.buildCopy(DstReg, ExtOp->getOperand(2).getReg());
ExtOp->eraseFromParent();
MI.eraseFromParent();

return true;
}

bool AIE2PreLegalizerCombinerImpl::tryToCombineIntrinsic(
MachineInstr &MI) const {

switch (cast<GIntrinsic>(MI).getIntrinsicID()) {
case Intrinsic::aie2_vshift_I512_I512: {
return CombineVecShiftByZero && tryToCombineVectorShiftsByZero(MI);
}
case Intrinsic::aie2_set_I512_I128: {
return tryToCombineSetExtract(MI);
}
default:
break;
}
Expand Down

0 comments on commit 9f14742

Please sign in to comment.