diff options
| author | Cameron McInally <cameron.mcinally@nyu.edu> | 2019-06-24 19:24:23 +0000 |
|---|---|---|
| committer | Cameron McInally <cameron.mcinally@nyu.edu> | 2019-06-24 19:24:23 +0000 |
| commit | fe3f15cf90015ba185ab6ce82f9686933dc475dc (patch) | |
| tree | f894fad9eaf1f29904de450f1b696e4806ba7ffd /llvm/lib/Transforms | |
| parent | 4412d83959f58c0eab10c5f6000022782ac5e91a (diff) | |
| download | bcm5719-llvm-fe3f15cf90015ba185ab6ce82f9686933dc475dc.tar.gz bcm5719-llvm-fe3f15cf90015ba185ab6ce82f9686933dc475dc.zip | |
[SLP] Support unary FNeg vectorization
Differential Revision: https://reviews.llvm.org/D63609
llvm-svn: 364219
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 2da9ead14ca..b3487cb3aa8 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2390,6 +2390,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, return; } case Instruction::Select: + case Instruction::FNeg: case Instruction::Add: case Instruction::FAdd: case Instruction::Sub: @@ -2409,7 +2410,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth, case Instruction::Or: case Instruction::Xor: { auto *TE = newTreeEntry(VL, true, UserTreeIdx, ReuseShuffleIndicies); - LLVM_DEBUG(dbgs() << "SLP: added a vector of bin op.\n"); + LLVM_DEBUG(dbgs() << "SLP: added a vector of un/bin op.\n"); // Sort operands of the instructions so that each side is more likely to // have the same opcode. @@ -2881,6 +2882,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) { int VecCost = TTI->getCmpSelInstrCost(S.getOpcode(), VecTy, MaskTy, VL0); return ReuseShuffleCost + VecCost - ScalarCost; } + case Instruction::FNeg: case Instruction::Add: case Instruction::FAdd: case Instruction::Sub: @@ -2918,7 +2920,8 @@ int BoUpSLP::getEntryCost(TreeEntry *E) { ConstantInt *CInt0 = nullptr; for (unsigned i = 0, e = VL.size(); i < e; ++i) { const Instruction *I = cast<Instruction>(VL[i]); - ConstantInt *CInt = dyn_cast<ConstantInt>(I->getOperand(1)); + unsigned OpIdx = isa<BinaryOperator>(I) ? 1 : 0; + ConstantInt *CInt = dyn_cast<ConstantInt>(I->getOperand(OpIdx)); if (!CInt) { Op2VK = TargetTransformInfo::OK_AnyValue; Op2VP = TargetTransformInfo::OP_None; @@ -3698,6 +3701,31 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { ++NumVectorInstructions; return V; } + case Instruction::FNeg: { + setInsertPointAfterBundle(E->Scalars, S); + + Value *Op = vectorizeTree(E->getOperand(0)); + + if (E->VectorizedValue) { + LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n"); + return E->VectorizedValue; + } + + Value *V = Builder.CreateUnOp( + static_cast<Instruction::UnaryOps>(S.getOpcode()), Op); + propagateIRFlags(V, E->Scalars, VL0); + if (auto *I = dyn_cast<Instruction>(V)) + V = propagateMetadata(I, E->Scalars); + + if (NeedToShuffleReuses) { + V = Builder.CreateShuffleVector(V, UndefValue::get(VecTy), + E->ReuseShuffleIndices, "shuffle"); + } + E->VectorizedValue = V; + ++NumVectorInstructions; + + return V; + } case Instruction::Add: case Instruction::FAdd: case Instruction::Sub: |

