[x86] Fix yet another issue with widening vector shuffle elements.
authorChandler Carruth <chandlerc@gmail.com>
Sat, 27 Sep 2014 08:40:33 +0000 (08:40 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 27 Sep 2014 08:40:33 +0000 (08:40 +0000)
I spotted this by inspection when debugging something else, so I have no
test case what-so-ever, and am not even sure it is possible to
realistically trigger the bug. But this is what was intended here.

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

lib/Target/X86/X86ISelLowering.cpp

index 17f925bd3e88b792152cdc11bc553357116f3785..4678340b6fb1d9d13b78b682d2d110304d25da8a 100644 (file)
@@ -9884,11 +9884,11 @@ static bool canWidenShuffleElements(ArrayRef<int> Mask,
 
     // Check for an undef mask and a mask value properly aligned to fit with
     // a pair of values. If we find such a case, use the non-undef mask's value.
 
     // Check for an undef mask and a mask value properly aligned to fit with
     // a pair of values. If we find such a case, use the non-undef mask's value.
-    if (Mask[i] == -1 && Mask[i + 1] % 2 == 1) {
+    if (Mask[i] == -1 && Mask[i + 1] >= 0 && Mask[i + 1] % 2 == 1) {
       WidenedMask.push_back(Mask[i + 1] / 2);
       continue;
     }
       WidenedMask.push_back(Mask[i + 1] / 2);
       continue;
     }
-    if (Mask[i + 1] == -1 && Mask[i] % 2 == 0) {
+    if (Mask[i + 1] == -1 && Mask[i] >= 0 && Mask[i] % 2 == 0) {
       WidenedMask.push_back(Mask[i] / 2);
       continue;
     }
       WidenedMask.push_back(Mask[i] / 2);
       continue;
     }