diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-06-20 14:26:28 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-06-20 14:26:28 +0000 |
| commit | 2e2f20a94926606269626a405c0fba54cf0f7ed1 (patch) | |
| tree | ae8a718565e8238f499cc1ab3326d9545d33f63d /llvm/lib/Transforms/Vectorize | |
| parent | 0c57de4c214a2b61811e247365a830cb70683a82 (diff) | |
| download | bcm5719-llvm-2e2f20a94926606269626a405c0fba54cf0f7ed1.tar.gz bcm5719-llvm-2e2f20a94926606269626a405c0fba54cf0f7ed1.zip | |
[SLPVectorizer] Relax "alternate" opcode vectorisation to work with any SK_Select shuffle pattern
D47985 saw the old SK_Alternate 'alternating' shuffle mask replaced with the SK_Select mask which accepts either input operand for each lane, equivalent to a vector select with a constant condition operand.
This patch updates SLPVectorizer to make full use of this SK_Select shuffle pattern by removing the 'isOdd()' limitation.
The AArch64 regression will be fixed by D48172.
Differential Revision: https://reviews.llvm.org/D48174
llvm-svn: 335130
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index dfa881aaa10..86e94f6d202 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -316,10 +316,6 @@ static unsigned getAltOpcode(unsigned Op) { } } -static bool isOdd(unsigned Value) { - return Value & 1; -} - static bool sameOpcodeOrAlt(unsigned Opcode, unsigned AltOpcode, unsigned CheckedOpcode) { return Opcode == CheckedOpcode || AltOpcode == CheckedOpcode; @@ -378,7 +374,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL) { unsigned AltOpcode = getAltOpcode(Opcode); for (int Cnt = 0, E = VL.size(); Cnt < E; Cnt++) { unsigned InstOpcode = cast<Instruction>(VL[Cnt])->getOpcode(); - if (InstOpcode != (isOdd(Cnt) ? AltOpcode : Opcode)) + if (!sameOpcodeOrAlt(Opcode, AltOpcode, InstOpcode)) return InstructionsState(VL[0], 0, false); } } @@ -3510,22 +3506,26 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { // Create shuffle to take alternate operations from the vector. // Also, gather up odd and even scalar ops to propagate IR flags to // each vector operation. - ValueList OddScalars, EvenScalars; + ValueList OpScalars, AltScalars; unsigned e = E->Scalars.size(); SmallVector<Constant *, 8> Mask(e); for (unsigned i = 0; i < e; ++i) { - if (isOdd(i)) { + auto *OpInst = cast<Instruction>(E->Scalars[i]); + unsigned InstOpcode = OpInst->getOpcode(); + assert(sameOpcodeOrAlt(S.Opcode, AltOpcode, InstOpcode) && + "Unexpected main/alternate opcode"); + if (InstOpcode == AltOpcode) { Mask[i] = Builder.getInt32(e + i); - OddScalars.push_back(E->Scalars[i]); + AltScalars.push_back(E->Scalars[i]); } else { Mask[i] = Builder.getInt32(i); - EvenScalars.push_back(E->Scalars[i]); + OpScalars.push_back(E->Scalars[i]); } } Value *ShuffleMask = ConstantVector::get(Mask); - propagateIRFlags(V0, EvenScalars); - propagateIRFlags(V1, OddScalars); + propagateIRFlags(V0, OpScalars); + propagateIRFlags(V1, AltScalars); Value *V = Builder.CreateShuffleVector(V0, V1, ShuffleMask); if (Instruction *I = dyn_cast<Instruction>(V)) |

