A new TTI interface has been added 'Optional <unsigned>getMaxVScale' that
returns the maximum vscale for a given target.
When known getMaxVScale is used to compute the cost of masked gather scatter
for scalable vector.
Depends on D92094
Differential D93030
[AArch64][SVE]Add cost model for masked gather and scatter for scalable vector. CarolineConcatto on Dec 10 2020, 5:45 AM. Authored by
Details A new TTI interface has been added 'Optional <unsigned>getMaxVScale' that Depends on D92094
Diff Detail
Event Timeline
Comment Actions Thank you @ctetreau and @sdesmalen for your reviews.
Comment Actions Assuming you have machine model for the FUJITSU A64FX. You should be able to get a lower value for getMaxVScale()? 512/128 -> 4 Even better, I invoked clang with -msve-vector-bits=128.
Comment Actions @tschuett I agree that we should refine the value if MaxVScale according to the Architecture by using flags.
Comment Actions LGTM with nits addressed and TODO removed.
Comment Actions Anyone else seeing crashes with this patch? I'm seeing something like this: UNREACHABLE executed at /usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/Support/MachineValueType.h:644! ... #0 0x00000000096fd56a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Unix/Signals.inc:563:11 #1 0x00000000096fd73b PrintStackTraceSignalHandler(void*) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Unix/Signals.inc:630:1 #2 0x00000000096fbd5b llvm::sys::RunSignalHandlers() /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Signals.cpp:70:5 #3 0x00000000096fde6d SignalHandler(int) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Unix/Signals.inc:405:1 #4 0x00007f220be59140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140) #5 0x00007f220b929c81 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:51:1 #6 0x00007f220b913537 abort ./stdlib/abort.c:81:7 #7 0x00000000096234c4 /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/ErrorHandling.cpp:213:3 #8 0x00000000063112f3 llvm::MVT::getVectorNumElements() const /usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/Support/MachineValueType.h:646:22 #9 0x000000000631121c llvm::MVT::getVectorElementCount() const /usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/Support/MachineValueType.h:791:32 #10 0x000000000658f5b9 llvm::AArch64TTIImpl::getGatherScatterOpCost(unsigned int, llvm::Type*, llvm::Value const*, bool, llvm::Align, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:778:36 #11 0x00000000064b17ac llvm::TargetTransformInfo::Model<llvm::AArch64TTIImpl>::getGatherScatterOpCost(unsigned int, llvm::Type*, llvm::Value const*, bool, llvm::Align, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) /usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/Analysis/TargetTransformInfo.h:2043:5 #12 0x0000000008216cae llvm::TargetTransformInfo::getGatherScatterOpCost(unsigned int, llvm::Type*, llvm::Value const*, bool, llvm::Align, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) const /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Analysis/TargetTransformInfo.cpp:875:23 #13 0x000000000994cf92 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry*) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3741:21 #14 0x000000000994f6cc llvm::slpvectorizer::BoUpSLP::getTreeCost() /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4055:25 #15 0x000000000995be1c llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool, llvm::ArrayRef<llvm::Value*>) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6264:32 #16 0x000000000995b684 llvm::SLPVectorizerPass::tryToVectorizePair(llvm::Value*, llvm::Value*, llvm::slpvectorizer::BoUpSLP&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6155:3 #17 0x000000000995c883 llvm::SLPVectorizerPass::tryToVectorize(llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6367:9 #18 0x000000000996b8f8 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Value*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*)::$_20::operator()(llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&) const /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:7484:5 #19 0x000000000996b8b8 bool llvm::function_ref<bool (llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&)>::callback_fn<llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Value*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*)::$_20>(long, llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/ADT/STLExtras.h:185:5 #20 0x0000000009989ac4 llvm::function_ref<bool (llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&)>::operator()(llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&) const /usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/ADT/STLExtras.h:209:5 #21 0x000000000995ceb2 tryToVectorizeHorReductionOrInstOperands(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::function_ref<bool (llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&)>) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:7455:9 #22 0x000000000995cb21 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Value*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:7486:3 #23 0x0000000009959c0f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:7665:20 #24 0x0000000009958f0c llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5954:16 #25 0x0000000009965558 (anonymous namespace)::SLPVectorizer::runOnFunction(llvm::Function&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5856:5 #26 0x0000000008ab24a2 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/IR/LegacyPassManager.cpp:1440:23 #27 0x0000000008ab7645 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/IR/LegacyPassManager.cpp:1486:16 #28 0x0000000008ab2e46 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/IR/LegacyPassManager.cpp:1555:23 #29 0x0000000008ab2976 llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/IR/LegacyPassManager.cpp:542:16 #30 0x0000000008ab7941 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/IR/LegacyPassManager.cpp:1682:3 #31 0x0000000009b109d1 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/CodeGen/BackendUtil.cpp:1013:3 #32 0x0000000009b0d273 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/CodeGen/BackendUtil.cpp:1576:5 #33 0x000000000a783d31 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/CodeGen/CodeGenAction.cpp:344:7 #34 0x000000000d1bcc58 clang::ParseAST(clang::Sema&, bool, bool) /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/Parse/ParseAST.cpp:178:12 #35 0x000000000a5acc0d clang::ASTFrontendAction::ExecuteAction() /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/Frontend/FrontendAction.cpp:1058:1 #36 0x000000000a77f718 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/CodeGen/CodeGenAction.cpp:1083:5 #37 0x000000000a5ac5d8 clang::FrontendAction::Execute() /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/Frontend/FrontendAction.cpp:953:7 #38 0x000000000a4c22d8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/Frontend/CompilerInstance.cpp:957:23 #39 0x000000000a76c714 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/blaikie/dev/llvm/src/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:8 #40 0x00000000062266fc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/blaikie/dev/llvm/src/clang/tools/driver/cc1_main.cpp:240:13 #41 0x0000000006218faa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /usr/local/google/home/blaikie/dev/llvm/src/clang/tools/driver/driver.cpp:330:5 #42 0x000000000621814d main /usr/local/google/home/blaikie/dev/llvm/src/clang/tools/driver/driver.cpp:407:5 Would be great to get this reverted while it's figured out - I can try to reduce a test case if no one else has something more portable/shareable - but probably worth reverting before that so other people aren't blocked by this as well? Comment Actions Thank you @dblaikie for pointing the problem. |
nit: The maximum value of vscale if the target specifies an architectural maximum vector length, and None otherwise.