]> granicus.if.org Git - llvm/commitdiff
[DAG] LegalizeVectorTypes - reduce scope of local variables. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 28 May 2019 13:46:26 +0000 (13:46 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 28 May 2019 13:46:26 +0000 (13:46 +0000)
Move the element index/count variables into the block where they are actually used - appeases cppcheck and helps avoid shadow variable warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361821 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

index 379ee00c90fbc476ca3f31af1a7048cdd432a18b..aefc2aabf64b4e12b34c79d32ef32296aedfadd6 100644 (file)
@@ -2812,14 +2812,13 @@ static SDValue CollectOpsToWiden(SelectionDAG &DAG, const TargetLowering &TLI,
 
   SDLoc dl(ConcatOps[0]);
   EVT WidenEltVT = WidenVT.getVectorElementType();
-  int Idx = 0;
 
   // while (Some element of ConcatOps is not of type MaxVT) {
   //   From the end of ConcatOps, collect elements of the same type and put
   //   them into an op of the next larger supported type
   // }
   while (ConcatOps[ConcatEnd-1].getValueType() != MaxVT) {
-    Idx = ConcatEnd - 1;
+    int Idx = ConcatEnd - 1;
     VT = ConcatOps[Idx--].getValueType();
     while (Idx >= 0 && ConcatOps[Idx].getValueType() == VT)
       Idx--;
@@ -4378,10 +4377,9 @@ SDValue DAGTypeLegalizer::WidenVecOp_MSCATTER(SDNode *N, unsigned OpNo) {
   SDValue Index = MSC->getIndex();
   SDValue Scale = MSC->getScale();
 
-  unsigned NumElts;
   if (OpNo == 1) {
     DataOp = GetWidenedVector(DataOp);
-    NumElts = DataOp.getValueType().getVectorNumElements();
+    unsigned NumElts = DataOp.getValueType().getVectorNumElements();
 
     // Widen index.
     EVT IndexVT = Index.getValueType();