From 155a92a4918f290e56869bec6360fd8dd6e3950d Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Wed, 10 Aug 2011 01:54:17 +0000 Subject: [PATCH] Fix a bug in vpermilps mask checking. Fix PR10560 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137194 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 9 ++++++--- test/CodeGen/X86/avx-vpermil.ll | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 3d3db6bf2f2..7e904e52525 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -3509,9 +3509,12 @@ static bool isVPERMILPSMask(const SmallVectorImpl &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; diff --git a/test/CodeGen/X86/avx-vpermil.ll b/test/CodeGen/X86/avx-vpermil.ll index f83a4450cf4..49b2f540a2c 100644 --- a/test/CodeGen/X86/avx-vpermil.ll +++ b/test/CodeGen/X86/avx-vpermil.ll @@ -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> + ret <8 x float> %shuffle +}