Skip to content

Commit 0f16d66

Browse files
committed
[NFC][CostModel] Refactor getCastInstrCost
Move ZExt/SExt load handling into the BasicTTI switch statement.
1 parent 75c3105 commit 0f16d66

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -702,24 +702,25 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
702702
case Instruction::ZExt:
703703
if (TLI->isZExtFree(SrcLT.second, DstLT.second))
704704
return 0;
705-
break;
706-
case Instruction::AddrSpaceCast:
707-
if (TLI->isFreeAddrSpaceCast(Src->getPointerAddressSpace(),
708-
Dst->getPointerAddressSpace()))
709-
return 0;
710-
break;
711-
}
712-
713-
// If this is a zext/sext of a load, return 0 if the corresponding
714-
// extending load exists on target.
715-
if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt) &&
716-
I && isa<LoadInst>(I->getOperand(0))) {
705+
LLVM_FALLTHROUGH;
706+
case Instruction::SExt: {
707+
// If this is a zext/sext of a load, return 0 if the corresponding
708+
// extending load exists on target.
709+
if (I && isa<LoadInst>(I->getOperand(0))) {
717710
EVT ExtVT = EVT::getEVT(Dst);
718711
EVT LoadVT = EVT::getEVT(Src);
719712
unsigned LType =
720713
((Opcode == Instruction::ZExt) ? ISD::ZEXTLOAD : ISD::SEXTLOAD);
721714
if (TLI->isLoadExtLegal(LType, ExtVT, LoadVT))
722715
return 0;
716+
}
717+
break;
718+
}
719+
case Instruction::AddrSpaceCast:
720+
if (TLI->isFreeAddrSpaceCast(Src->getPointerAddressSpace(),
721+
Dst->getPointerAddressSpace()))
722+
return 0;
723+
break;
723724
}
724725

725726
// If the cast is marked as legal (or promote) then assume low cost.

0 commit comments

Comments
 (0)