Skip to content

Commit 65220fc

Browse files
authored
[PPC] Fix coding style violations in PPCTargetTransformInfo.cpp (llvm#130666)
Fixing violations of the coding conventions. Applying clang-tidy recommendations.
1 parent d06937a commit 65220fc

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ PPCTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
112112

113113
// Check that all of the elements are integer constants or undefs.
114114
bool AllEltsOk = true;
115-
for (unsigned i = 0; i != 16; ++i) {
116-
Constant *Elt = Mask->getAggregateElement(i);
115+
for (unsigned I = 0; I != 16; ++I) {
116+
Constant *Elt = Mask->getAggregateElement(I);
117117
if (!Elt || !(isa<ConstantInt>(Elt) || isa<UndefValue>(Elt))) {
118118
AllEltsOk = false;
119119
break;
@@ -132,11 +132,11 @@ PPCTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
132132
Value *ExtractedElts[32];
133133
memset(ExtractedElts, 0, sizeof(ExtractedElts));
134134

135-
for (unsigned i = 0; i != 16; ++i) {
136-
if (isa<UndefValue>(Mask->getAggregateElement(i)))
135+
for (unsigned I = 0; I != 16; ++I) {
136+
if (isa<UndefValue>(Mask->getAggregateElement(I)))
137137
continue;
138138
unsigned Idx =
139-
cast<ConstantInt>(Mask->getAggregateElement(i))->getZExtValue();
139+
cast<ConstantInt>(Mask->getAggregateElement(I))->getZExtValue();
140140
Idx &= 31; // Match the hardware behavior.
141141
if (DL.isLittleEndian())
142142
Idx = 31 - Idx;
@@ -150,7 +150,7 @@ PPCTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
150150

151151
// Insert this value into the result vector.
152152
Result = IC.Builder.CreateInsertElement(Result, ExtractedElts[Idx],
153-
IC.Builder.getInt32(i));
153+
IC.Builder.getInt32(I));
154154
}
155155
return CastInst::Create(Instruction::BitCast, Result, II.getType());
156156
}
@@ -457,16 +457,15 @@ unsigned PPCTTIImpl::getNumberOfRegisters(unsigned ClassID) const {
457457
unsigned PPCTTIImpl::getRegisterClassForType(bool Vector, Type *Ty) const {
458458
if (Vector)
459459
return ST->hasVSX() ? VSXRC : VRRC;
460-
else if (Ty && (Ty->getScalarType()->isFloatTy() ||
461-
Ty->getScalarType()->isDoubleTy()))
460+
if (Ty &&
461+
(Ty->getScalarType()->isFloatTy() || Ty->getScalarType()->isDoubleTy()))
462462
return ST->hasVSX() ? VSXRC : FPRRC;
463-
else if (Ty && (Ty->getScalarType()->isFP128Ty() ||
464-
Ty->getScalarType()->isPPC_FP128Ty()))
463+
if (Ty && (Ty->getScalarType()->isFP128Ty() ||
464+
Ty->getScalarType()->isPPC_FP128Ty()))
465465
return VRRC;
466-
else if (Ty && Ty->getScalarType()->isHalfTy())
466+
if (Ty && Ty->getScalarType()->isHalfTy())
467467
return VSXRC;
468-
else
469-
return GPRRC;
468+
return GPRRC;
470469
}
471470

472471
const char* PPCTTIImpl::getRegisterClassName(unsigned ClassID) const {
@@ -694,8 +693,8 @@ InstructionCost PPCTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
694693
return 0;
695694

696695
return Cost;
697-
698-
} else if (Val->getScalarType()->isIntegerTy()) {
696+
}
697+
if (Val->getScalarType()->isIntegerTy()) {
699698
unsigned EltSize = Val->getScalarSizeInBits();
700699
// Computing on 1 bit values requires extra mask or compare operations.
701700
unsigned MaskCostForOneBitSize = (VecMaskCost && EltSize == 1) ? 1 : 0;
@@ -709,15 +708,15 @@ InstructionCost PPCTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
709708
if (ISD == ISD::INSERT_VECTOR_ELT) {
710709
if (ST->hasP10Vector())
711710
return CostFactor + MaskCostForIdx;
712-
else if (Index != -1U)
711+
if (Index != -1U)
713712
return 2 * CostFactor;
714713
} else if (ISD == ISD::EXTRACT_VECTOR_ELT) {
715714
// It's an extract. Maybe we can do a cheap move-from VSR.
716715
unsigned EltSize = Val->getScalarSizeInBits();
717716
// P9 has both mfvsrd and mfvsrld for 64 bit integer.
718717
if (EltSize == 64 && Index != -1U)
719718
return 1;
720-
else if (EltSize == 32) {
719+
if (EltSize == 32) {
721720
unsigned MfvsrwzIndex = ST->isLittleEndian() ? 2 : 1;
722721
if (Index == MfvsrwzIndex)
723722
return 1;
@@ -847,9 +846,9 @@ InstructionCost PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
847846
// stores, loads are expanded using the vector-load + permutation sequence,
848847
// which is much less expensive).
849848
if (Src->isVectorTy() && Opcode == Instruction::Store)
850-
for (int i = 0, e = cast<FixedVectorType>(Src)->getNumElements(); i < e;
851-
++i)
852-
Cost += getVectorInstrCost(Instruction::ExtractElement, Src, CostKind, i,
849+
for (int I = 0, E = cast<FixedVectorType>(Src)->getNumElements(); I < E;
850+
++I)
851+
Cost += getVectorInstrCost(Instruction::ExtractElement, Src, CostKind, I,
853852
nullptr, nullptr);
854853

855854
return Cost;
@@ -960,8 +959,7 @@ bool PPCTTIImpl::isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
960959
C1.NumBaseAdds, C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
961960
std::tie(C2.Insns, C2.NumRegs, C2.AddRecCost, C2.NumIVMuls,
962961
C2.NumBaseAdds, C2.ScaleCost, C2.ImmCost, C2.SetupCost);
963-
else
964-
return TargetTransformInfoImplBase::isLSRCostLess(C1, C2);
962+
return TargetTransformInfoImplBase::isLSRCostLess(C1, C2);
965963
}
966964

967965
bool PPCTTIImpl::isNumRegsMajorCostOfLSR() {

0 commit comments

Comments
 (0)