[x86] Switch to a formulation of a for loop that is much more obviously
authorChandler Carruth <chandlerc@gmail.com>
Wed, 6 Aug 2014 10:16:33 +0000 (10:16 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 6 Aug 2014 10:16:33 +0000 (10:16 +0000)
not corrupting the mask by mutating it more times than intended. No
functionality changed (the results were non-overlapping so the old
version "worked" but was non-obvious).

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

lib/Target/X86/X86ISelLowering.cpp

index 18b3bb25caee2c7be7c46452195e85d966fa5b45..7bf58e20dacf29d90bf3035fc01cefdfe136bc4d 100644 (file)
@@ -7519,9 +7519,10 @@ static SDValue lowerV8I16SingleInputVectorShuffle(
     int FreeDWord = (PSHUFDMask[DestOffset / 2] == -1 ? 0 : 1) + DestOffset / 2;
     assert(PSHUFDMask[FreeDWord] == -1 && "DWord not free");
     PSHUFDMask[FreeDWord] = IncomingInputs[0] / 2;
-    for (int Input : IncomingInputs)
-      std::replace(HalfMask.begin(), HalfMask.end(), Input,
-                   FreeDWord * 2 + Input % 2);
+    for (int &M : HalfMask)
+      for (int Input : IncomingInputs)
+        if (M == Input)
+          M = FreeDWord * 2 + Input % 2;
   };
   moveInputsToRightHalf(HToLInputs, LToLInputs, PSHUFHMask, LoMask,
                         /*SourceOffset*/ 4, /*DestOffset*/ 0);