]> granicus.if.org Git - llvm/commitdiff
[X86] lowerVectorShuffle - use any_of to detect out of bounds shuffle indices. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 6 May 2019 10:11:24 +0000 (10:11 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 6 May 2019 10:11:24 +0000 (10:11 +0000)
Fixes cppcheck local shadow warning as well.

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

lib/Target/X86/X86ISelLowering.cpp

index fc100fe4871b4fcca26e2decff8be530764624d1..1750d070062c9d3d9b09923fba62f1fb5e475067 100644 (file)
@@ -16470,15 +16470,14 @@ static SDValue lowerVectorShuffle(SDValue Op, const X86Subtarget &Subtarget,
   // Check for non-undef masks pointing at an undef vector and make the masks
   // undef as well. This makes it easier to match the shuffle based solely on
   // the mask.
-  if (V2IsUndef)
-    for (int M : Mask)
-      if (M >= NumElements) {
-        SmallVector<int, 8> NewMask(Mask.begin(), Mask.end());
-        for (int &M : NewMask)
-          if (M >= NumElements)
-            M = -1;
-        return DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
-      }
+  if (V2IsUndef &&
+      any_of(Mask, [NumElements](int M) { return M >= NumElements; })) {
+    SmallVector<int, 8> NewMask(Mask.begin(), Mask.end());
+    for (int &M : NewMask)
+      if (M >= NumElements)
+        M = -1;
+    return DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
+  }
 
   // Check for illegal shuffle mask element index values.
   int MaskUpperLimit = Mask.size() * (V2IsUndef ? 1 : 2); (void)MaskUpperLimit;