Skip to content

Commit a7252d9

Browse files
committed
self review of loops
1 parent a0f5473 commit a7252d9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6403,10 +6403,10 @@ void CodeGenFunction::FlattenAccessAndType(
64036403
for (auto *FD : Record->fields())
64046404
FieldTypes.push_back(FD->getType());
64056405

6406-
for (int64_t i = FieldTypes.size() - 1; i > -1; i--) {
6406+
for (int64_t I = FieldTypes.size() - 1; I > -1; I--) {
64076407
llvm::SmallVector<llvm::Value *, 4> IdxListCopy = IdxList;
6408-
IdxListCopy.push_back(llvm::ConstantInt::get(IdxTy, i));
6409-
WorkList.insert(WorkList.end(), {FieldTypes[i], IdxListCopy});
6408+
IdxListCopy.push_back(llvm::ConstantInt::get(IdxTy, I));
6409+
WorkList.insert(WorkList.end(), {FieldTypes[I], IdxListCopy});
64106410
}
64116411
} else if (const auto *VT = dyn_cast<VectorType>(T)) {
64126412
llvm::Type *LLVMT = ConvertTypeForMem(T);

clang/lib/CodeGen/CGExprAgg.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -545,22 +545,22 @@ static void EmitHLSLAggregateFlatCast(CodeGenFunction &CGF, Address DestVal,
545545
has less elements than flattened destination object.");
546546
// apply casts to what we load from LoadGEPList
547547
// and store result in Dest
548-
for (unsigned i = 0; i < StoreGEPList.size(); i++) {
549-
llvm::Value *Idx = LoadGEPList[i].second;
550-
llvm::Value *Load = CGF.Builder.CreateLoad(LoadGEPList[i].first, "load");
548+
for (unsigned I = 0, E = StoreGEPList.size(); I < E; I++) {
549+
llvm::Value *Idx = LoadGEPList[I].second;
550+
llvm::Value *Load = CGF.Builder.CreateLoad(LoadGEPList[I].first, "load");
551551
Load =
552552
Idx ? CGF.Builder.CreateExtractElement(Load, Idx, "vec.extract") : Load;
553553
llvm::Value *Cast =
554-
CGF.EmitScalarConversion(Load, SrcTypes[i], DestTypes[i], Loc);
554+
CGF.EmitScalarConversion(Load, SrcTypes[I], DestTypes[I], Loc);
555555

556556
// store back
557-
Idx = StoreGEPList[i].second;
557+
Idx = StoreGEPList[I].second;
558558
if (Idx) {
559559
llvm::Value *V =
560-
CGF.Builder.CreateLoad(StoreGEPList[i].first, "load.for.insert");
560+
CGF.Builder.CreateLoad(StoreGEPList[I].first, "load.for.insert");
561561
Cast = CGF.Builder.CreateInsertElement(V, Cast, Idx);
562562
}
563-
CGF.Builder.CreateStore(Cast, StoreGEPList[i].first);
563+
CGF.Builder.CreateStore(Cast, StoreGEPList[I].first);
564564
}
565565
}
566566

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,8 +2500,10 @@ bool SemaHLSL::CanPerformAggregateCast(Expr *Src, QualType DestTy) {
25002500
if (SrcTypes.size() < DestTypes.size())
25012501
return false;
25022502

2503+
unsigned SrcSize = SrcTypes.size();
2504+
unsigned DstSize = DestTypes.size();
25032505
unsigned I;
2504-
for (I = 0; I < DestTypes.size() && I < SrcTypes.size(); I++) {
2506+
for (I = 0; I < DstSize && I < SrcSize; I++) {
25052507
if (SrcTypes[I]->isUnionType() || DestTypes[I]->isUnionType())
25062508
return false;
25072509
if (!CanPerformScalarCast(SrcTypes[I], DestTypes[I])) {
@@ -2510,7 +2512,7 @@ bool SemaHLSL::CanPerformAggregateCast(Expr *Src, QualType DestTy) {
25102512
}
25112513

25122514
// check the rest of the source type for unions.
2513-
for (; I < SrcTypes.size(); I++) {
2515+
for (; I < SrcSize; I++) {
25142516
if (SrcTypes[I]->isUnionType())
25152517
return false;
25162518
}

0 commit comments

Comments
 (0)