diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-09-02 16:41:55 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-09-02 16:41:55 +0000 |
commit | 6bf02adee0ef1a90207baec042d6781d562ed282 (patch) | |
tree | c1ea797b0e2567cc278c6e8f21c1da5c53851fe0 /lib/Transforms/Vectorize/LoopVectorize.cpp | |
parent | efeac0e5c0aab7476a4165e73d4b5f966c9468b0 (diff) |
[LoopVectorize] Turn static DenseSet into switch.
LLVM transforms this into a bit test which is a lot faster and smaller.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r-- | lib/Transforms/Vectorize/LoopVectorize.cpp | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index 955134077bb..d7fdb666880 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7987,22 +7987,53 @@ VPWidenRecipe *LoopVectorizationPlanner::tryToWiden( if (Legal->isScalarWithPredication(I)) return nullptr; - static DenseSet<unsigned> VectorizableOpcodes = { - Instruction::Br, Instruction::PHI, Instruction::GetElementPtr, - Instruction::UDiv, Instruction::SDiv, Instruction::SRem, - Instruction::URem, Instruction::Add, Instruction::FAdd, - Instruction::Sub, Instruction::FSub, Instruction::Mul, - Instruction::FMul, Instruction::FDiv, Instruction::FRem, - Instruction::Shl, Instruction::LShr, Instruction::AShr, - Instruction::And, Instruction::Or, Instruction::Xor, - Instruction::Select, Instruction::ICmp, Instruction::FCmp, - Instruction::Store, Instruction::Load, Instruction::ZExt, - Instruction::SExt, Instruction::FPToUI, Instruction::FPToSI, - Instruction::FPExt, Instruction::PtrToInt, Instruction::IntToPtr, - Instruction::SIToFP, Instruction::UIToFP, Instruction::Trunc, - Instruction::FPTrunc, Instruction::BitCast, Instruction::Call}; - - if (!VectorizableOpcodes.count(I->getOpcode())) + auto IsVectorizableOpcode = [](unsigned Opcode) { + switch (Opcode) { + case Instruction::Add: + case Instruction::And: + case Instruction::AShr: + case Instruction::BitCast: + case Instruction::Br: + case Instruction::Call: + case Instruction::FAdd: + case Instruction::FCmp: + case Instruction::FDiv: + case Instruction::FMul: + case Instruction::FPExt: + case Instruction::FPToSI: + case Instruction::FPToUI: + case Instruction::FPTrunc: + case Instruction::FRem: + case Instruction::FSub: + case Instruction::GetElementPtr: + case Instruction::ICmp: + case Instruction::IntToPtr: + case Instruction::Load: + case Instruction::LShr: + case Instruction::Mul: + case Instruction::Or: + case Instruction::PHI: + case Instruction::PtrToInt: + case Instruction::SDiv: + case Instruction::Select: + case Instruction::SExt: + case Instruction::Shl: + case Instruction::SIToFP: + case Instruction::SRem: + case Instruction::Store: + case Instruction::Sub: + case Instruction::Trunc: + case Instruction::UDiv: + case Instruction::UIToFP: + case Instruction::URem: + case Instruction::Xor: + case Instruction::ZExt: + return true; + } + return false; + }; + + if (!IsVectorizableOpcode(I->getOpcode())) return nullptr; if (CallInst *CI = dyn_cast<CallInst>(I)) { |