@@ -704,28 +704,33 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
704
704
std::pair<unsigned , MVT> SrcLT = TLI->getTypeLegalizationCost (DL, Src);
705
705
std::pair<unsigned , MVT> DstLT = TLI->getTypeLegalizationCost (DL, Dst);
706
706
707
- // Check for NOOP conversions.
708
- if (SrcLT.first == DstLT.first &&
709
- SrcLT.second .getSizeInBits () == DstLT.second .getSizeInBits ()) {
707
+ unsigned SrcSize = SrcLT.second .getSizeInBits ();
708
+ unsigned DstSize = DstLT.second .getSizeInBits ();
710
709
710
+ switch (Opcode) {
711
+ default :
712
+ break ;
713
+ case Instruction::Trunc:
714
+ // Check for NOOP conversions.
715
+ if (TLI->isTruncateFree (SrcLT.second , DstLT.second ))
716
+ return 0 ;
717
+ LLVM_FALLTHROUGH;
718
+ case Instruction::BitCast:
711
719
// Bitcast between types that are legalized to the same type are free.
712
- if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)
720
+ if (SrcLT.first == DstLT.first && SrcSize == DstSize)
721
+ return 0 ;
722
+ break ;
723
+ case Instruction::ZExt:
724
+ if (TLI->isZExtFree (SrcLT.second , DstLT.second ))
725
+ return 0 ;
726
+ break ;
727
+ case Instruction::AddrSpaceCast:
728
+ if (TLI->isFreeAddrSpaceCast (Src->getPointerAddressSpace (),
729
+ Dst->getPointerAddressSpace ()))
713
730
return 0 ;
731
+ break ;
714
732
}
715
733
716
- if (Opcode == Instruction::Trunc &&
717
- TLI->isTruncateFree (SrcLT.second , DstLT.second ))
718
- return 0 ;
719
-
720
- if (Opcode == Instruction::ZExt &&
721
- TLI->isZExtFree (SrcLT.second , DstLT.second ))
722
- return 0 ;
723
-
724
- if (Opcode == Instruction::AddrSpaceCast &&
725
- TLI->isFreeAddrSpaceCast (Src->getPointerAddressSpace (),
726
- Dst->getPointerAddressSpace ()))
727
- return 0 ;
728
-
729
734
// If this is a zext/sext of a load, return 0 if the corresponding
730
735
// extending load exists on target.
731
736
if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt) &&
0 commit comments