[InstCombine] simplify loop for shuffle mask canonicalization; NFC
authorSanjay Patel <spatel@rotateright.com>
Mon, 25 Nov 2019 15:40:21 +0000 (10:40 -0500)
committerSanjay Patel <spatel@rotateright.com>
Mon, 25 Nov 2019 15:41:50 +0000 (10:41 -0500)
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

index 54298949cbab26f2ce21f1a223fe12902e7fef53..eae8bd7452d43067d4ff2b4a102c35b642bdaac5 100644 (file)
@@ -1893,18 +1893,18 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
   if (LHS == RHS || isa<UndefValue>(LHS)) {
     // Remap any references to RHS to use LHS.
     SmallVector<Constant*, 16> Elts;
-    for (unsigned i = 0, e = LHSWidth; i != VWidth; ++i) {
+    for (unsigned i = 0; i != VWidth; ++i) {
       if (Mask[i] < 0) {
         Elts.push_back(UndefValue::get(Int32Ty));
         continue;
       }
 
-      if ((Mask[i] >= (int)e && isa<UndefValue>(RHS)) ||
-          (Mask[i] <  (int)e && isa<UndefValue>(LHS))) {
+      if ((Mask[i] >= (int)LHSWidth && isa<UndefValue>(RHS)) ||
+          (Mask[i] <  (int)LHSWidth && isa<UndefValue>(LHS))) {
         Mask[i] = -1;     // Turn into undef.
         Elts.push_back(UndefValue::get(Int32Ty));
       } else {
-        Mask[i] = Mask[i] % e;  // Force to LHS.
+        Mask[i] = Mask[i] % LHSWidth;  // Force to LHS.
         Elts.push_back(ConstantInt::get(Int32Ty, Mask[i]));
       }
     }