Skip to content

Commit 0f74a51

Browse files
committed
Replace right shift with division
1 parent d1409b8 commit 0f74a51

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
11211121
unsigned DstEltSize = Dst->getScalarSizeInBits();
11221122
InstructionCost Cost = 0;
11231123
if ((SrcEltSize == 16) &&
1124-
(!ST->hasVInstructionsF16() || ((DstEltSize >> 1) > SrcEltSize))) {
1124+
(!ST->hasVInstructionsF16() || ((DstEltSize / 2) > SrcEltSize))) {
11251125
// If the target only supports vfhmin or it is fp16-to-i64 conversion
11261126
// pre-widening to f32 and then convert f32 to integer
11271127
VectorType *VecF32Ty =
@@ -1142,10 +1142,10 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
11421142
else { // (SrcEltSize > DstEltSize)
11431143
// First do a narrowing conversion to an integer half the size, then
11441144
// truncate if needed.
1145-
MVT ElementVT = MVT::getIntegerVT(SrcEltSize >> 1);
1145+
MVT ElementVT = MVT::getIntegerVT(SrcEltSize / 2);
11461146
MVT VecVT = DstLT.second.changeVectorElementType(ElementVT);
11471147
Cost += getRISCVInstructionCost(FNCVT, VecVT, CostKind);
1148-
if ((SrcEltSize >> 1) > DstEltSize) {
1148+
if ((SrcEltSize / 2) > DstEltSize) {
11491149
Type *VecTy = EVT(VecVT).getTypeForEVT(Dst->getContext());
11501150
Cost +=
11511151
getCastInstrCost(Instruction::Trunc, Dst, VecTy, CCH, CostKind, I);
@@ -1164,7 +1164,7 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
11641164

11651165
InstructionCost Cost = 0;
11661166
if ((DstEltSize == 16) &&
1167-
(!ST->hasVInstructionsF16() || ((SrcEltSize >> 1) > DstEltSize))) {
1167+
(!ST->hasVInstructionsF16() || ((SrcEltSize / 2) > DstEltSize))) {
11681168
// If the target only supports vfhmin or it is i64-to-fp16 conversion
11691169
// it is converted to f32 and then converted to f16
11701170
VectorType *VecF32Ty =
@@ -1181,8 +1181,8 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
11811181
if (DstEltSize == SrcEltSize)
11821182
Cost += getRISCVInstructionCost(FCVT, DstLT.second, CostKind);
11831183
else if (DstEltSize > SrcEltSize) {
1184-
if ((DstEltSize >> 1) > SrcEltSize) {
1185-
SrcEltSize = DstEltSize >> 1;
1184+
if ((DstEltSize / 2) > SrcEltSize) {
1185+
SrcEltSize = DstEltSize / 2;
11861186
VectorType *VecTy =
11871187
VectorType::get(IntegerType::get(Dst->getContext(), SrcEltSize),
11881188
cast<VectorType>(Dst)->getElementCount());

0 commit comments

Comments
 (0)