Fix a bug in vpermilps mask checking. Fix PR10560
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 10 Aug 2011 01:54:17 +0000 (01:54 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 10 Aug 2011 01:54:17 +0000 (01:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137194 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/avx-vpermil.ll

index 3d3db6bf2f2fc9038b10c383929d21dc183cdc68..7e904e52525755b9ad7aae6466c69b1cbb59d0de 100644 (file)
@@ -3509,9 +3509,12 @@ static bool isVPERMILPSMask(const SmallVectorImpl<int> &Mask, EVT VT,
   int LaneSize = NumElts/NumLanes;
   for (int i = 0; i < LaneSize; ++i) {
     int HighElt = i+LaneSize;
-    if (Mask[i] < 0 && (isUndefOrInRange(Mask[HighElt], LaneSize, NumElts)))
-      continue;
-    if (Mask[HighElt] < 0 && (isUndefOrInRange(Mask[i], 0, LaneSize)))
+    bool HighValid = isUndefOrInRange(Mask[HighElt], LaneSize, NumElts);
+    bool LowValid = isUndefOrInRange(Mask[i], 0, LaneSize);
+
+    if (!HighValid || !LowValid)
+      return false;
+    if (Mask[i] < 0 || Mask[HighElt] < 0)
       continue;
     if (Mask[HighElt]-Mask[i] != LaneSize)
       return false;
index f83a4450cf4bbd836d19458f45282dd4e596a126..49b2f540a2c779a00dbdf6ad4ac84aeda076a2f9 100644 (file)
@@ -37,3 +37,9 @@ entry:
   ret <8 x float> %shuffle
 }
 
+; CHECK-NOT: vpermilps
+define <8 x float> @funcF(<8 x float> %a) nounwind uwtable readnone ssp {
+entry:
+  %shuffle = shufflevector <8 x float> %a, <8 x float> zeroinitializer, <8 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9>
+  ret <8 x float> %shuffle
+}