getCastInstrCost()

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 12:55:04 PST 2017


On 02/01/2017 09:19 AM, Jonas Paulsson via llvm-commits wrote:
> Hi,
>
> It seems odd to think that a vector truncate could be a noop in 
> getCastInstrCost().
>
> Add a check so that this only applies to scalar types.

Agreed (please commit with a test case).

  -Hal

>
> /Jonas
>
>
>    unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src) {
>      const TargetLoweringBase *TLI = getTLI();
>      int ISD = TLI->InstructionOpcodeToISD(Opcode);
>      assert(ISD && "Invalid opcode");
>      std::pair<unsigned, MVT> SrcLT = TLI->getTypeLegalizationCost(DL, 
> Src);
>      std::pair<unsigned, MVT> DstLT = TLI->getTypeLegalizationCost(DL, 
> Dst);
>
>      // Check for NOOP conversions.
> -    if (SrcLT.first == DstLT.first &&
> +    if ((!Src->isVectorTy() && !Dst->isVectorTy()) &&
> +        SrcLT.first == DstLT.first &&
>          SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {
>
>        // Bitcast between types that are legalized to the same type 
> are free.
>       if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)
>          return 0;
>      }
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list