Commit 0f16d66c authored by Sam Parker's avatar Sam Parker
Browse files

[NFC][CostModel] Refactor getCastInstrCost

Move ZExt/SExt load handling into the BasicTTI switch statement.
parent 75c31057
......@@ -702,24 +702,25 @@ public:
case Instruction::ZExt:
if (TLI->isZExtFree(SrcLT.second, DstLT.second))
return 0;
break;
case Instruction::AddrSpaceCast:
if (TLI->isFreeAddrSpaceCast(Src->getPointerAddressSpace(),
Dst->getPointerAddressSpace()))
return 0;
break;
}
// If this is a zext/sext of a load, return 0 if the corresponding
// extending load exists on target.
if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt) &&
I && isa<LoadInst>(I->getOperand(0))) {
LLVM_FALLTHROUGH;
case Instruction::SExt: {
// If this is a zext/sext of a load, return 0 if the corresponding
// extending load exists on target.
if (I && isa<LoadInst>(I->getOperand(0))) {
EVT ExtVT = EVT::getEVT(Dst);
EVT LoadVT = EVT::getEVT(Src);
unsigned LType =
((Opcode == Instruction::ZExt) ? ISD::ZEXTLOAD : ISD::SEXTLOAD);
if (TLI->isLoadExtLegal(LType, ExtVT, LoadVT))
return 0;
}
break;
}
case Instruction::AddrSpaceCast:
if (TLI->isFreeAddrSpaceCast(Src->getPointerAddressSpace(),
Dst->getPointerAddressSpace()))
return 0;
break;
}
// If the cast is marked as legal (or promote) then assume low cost.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment