[x86] Fix another miscompile found through fuzz testing the new vector
[oota-llvm.git] / lib / Target / X86 / X86ISelLowering.cpp
index d85ac5e55e43389aa694247e9bce8a229873163a..c62c2fd5f3584a0c0437208f1ba8200b16c8d226 100644 (file)
@@ -7546,10 +7546,10 @@ static SDValue lowerV8I16SingleInputVectorShuffle(
           // We also have to update the final source mask in this case because
           // it may need to undo the above swap.
           for (int &M : FinalSourceHalfMask)
-            if (M == (InputsFixed[0] ^ 1))
-              M = InputsFixed[1];
-            else if (M == InputsFixed[1])
-              M = InputsFixed[0] ^ 1;
+            if (M == (InputsFixed[0] ^ 1) + SourceOffset)
+              M = InputsFixed[1] + SourceOffset;
+            else if (M == InputsFixed[1] + SourceOffset)
+              M = InputsFixed[0] ^ 1 + SourceOffset;
 
           InputsFixed[1] = InputsFixed[0] ^ 1;
         }