From 65bf236286bed8bbca69df8f8fe71fb702bf67c7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 15 Oct 2019 11:13:51 +0000 Subject: [PATCH] [X86] Resolve KnownUndef/KnownZero bits into target shuffle masks in helper. NFCI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374878 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 0e5a397fa93..86f1c20020d 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -6807,6 +6807,22 @@ static bool getTargetShuffleAndZeroables(SDValue N, SmallVectorImpl &Mask, return true; } +// Replace target shuffle mask elements with known undef/zero sentinels. +static void resolveTargetShuffleAndZeroables(SmallVectorImpl &Mask, + const APInt &KnownUndef, + const APInt &KnownZero) { + unsigned NumElts = Mask.size(); + assert(KnownUndef.getBitWidth() == NumElts && + KnownZero.getBitWidth() == NumElts && "Shuffle mask size mismatch"); + + for (unsigned i = 0; i != NumElts; ++i) { + if (KnownUndef[i]) + Mask[i] = SM_SentinelUndef; + else if (KnownZero[i]) + Mask[i] = SM_SentinelZero; + } +} + // Forward declaration (for getFauxShuffleMask recursive check). // TODO: Use DemandedElts variant. static bool getTargetShuffleInputs(SDValue Op, SmallVectorImpl &Inputs, @@ -7256,15 +7272,8 @@ static bool getTargetShuffleInputs(SDValue Op, const APInt &DemandedElts, return false; if (getTargetShuffleAndZeroables(Op, Mask, Inputs, KnownUndef, KnownZero)) { - for (int i = 0, e = Mask.size(); i != e; ++i) { - int &M = Mask[i]; - if (M < 0 || !ResolveKnownElts) - continue; - if (KnownUndef[i]) - M = SM_SentinelUndef; - else if (KnownZero[i]) - M = SM_SentinelZero; - } + if (ResolveKnownElts) + resolveTargetShuffleAndZeroables(Mask, KnownUndef, KnownZero); return true; } if (getFauxShuffleMask(Op, DemandedElts, Mask, Inputs, DAG, Depth, -- 2.40.0