[llvm] [RISCV][CostModel] VPIntrinsics have same cost as their non-vp counterparts (PR #67178)

Stella Laurenzo via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 11:29:07 PDT 2023


stellaraccident wrote:

Hi there - we bisected to this change in a downstream compiler crash (on x86, I think due to the common codegen change). Here is the stack trace:

```
FAILED: tests/e2e/stablehlo_ops/check_llvm-cpu_local-task_reduce.mlir_module.vmfb /work/full-build-dir/tests/e2e/stablehlo_ops/check_llvm-cpu_local-task_reduce.mlir_module.vmfb 
cd /work/full-build-dir/tests/e2e/stablehlo_ops && /work/full-build-dir/tools/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu --iree-input-type=stablehlo /work/tests/e2e/stablehlo_ops/reduce.mlir -o check_llvm-cpu_local-task_reduce.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/full-build-dir\" --iree-llvmcpu-embedded-linker-path=\"/work/full-build-dir/llvm-project/bin/lld\" --iree-llvmcpu-wasm-linker-path=\"/work/full-build-dir/llvm-project/bin/lld\"
iree-compile: /work/third_party/llvm-project/llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From *) [To = llvm::PointerType, From = llvm::Type]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
Please report issues to https://github.com/openxla/iree/issues and include the crash backtrace.
Stack dump:
0.	Program arguments: /work/full-build-dir/tools/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu --iree-input-type=stablehlo /work/tests/e2e/stablehlo_ops/reduce.mlir -o check_llvm-cpu_local-task_reduce.mlir_module.vmfb --iree-hal-executable-object-search-path=\"/work/full-build-dir\" --iree-llvmcpu-embedded-linker-path=\"/work/full-build-dir/llvm-project/bin/lld\" --iree-llvmcpu-wasm-linker-path=\"/work/full-build-dir/llvm-project/bin/lld\"
 #0 0x00007fb3fd68375b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /work/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x00007fb3fd6817b0 llvm::sys::RunSignalHandlers() /work/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00007fb3fd683e3f SignalHandler(int) /work/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007fb404b23420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fb3f6c6f00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fb3f6c4e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007fb3f6c4e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007fb3f6c5ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x00007fb40161f5dd (/work/full-build-dir/lib/libIREECompiler.so+0xa61f5dd)
 #9 0x00007fb40198d6f6 llvm::EVT::isSimple() const /work/third_party/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:130:25
#10 0x00007fb40198d6f6 llvm::X86TTIImpl::getArithmeticReductionCost(unsigned int, llvm::VectorType*, std::optional<llvm::FastMathFlags>, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/lib/Target/X86/X86TargetTransformInfo.cpp:5078:10
#11 0x00007fb401995cee llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getTypeBasedIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/include/llvm/CodeGen/BasicTTIImpl.h:0:0
#12 0x00007fb4019888a0 llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/include/llvm/CodeGen/BasicTTIImpl.h:0:0
#13 0x00007fb401988620 llvm::X86TTIImpl::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/lib/Target/X86/X86TargetTransformInfo.cpp:4334:17
#14 0x00007fb40198980c llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/include/llvm/CodeGen/BasicTTIImpl.h:1741:25
#15 0x00007fb401988620 llvm::X86TTIImpl::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/lib/Target/X86/X86TargetTransformInfo.cpp:4334:17
#16 0x00007fb4018b0852 llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) /work/third_party/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:1138:25
#17 0x00007fb403d5f3ed llvm::TargetTransformInfo::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) const /work/third_party/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp:266:3
#18 0x00007fb402bd7349 llvm::TargetTransformInfo::getInstructionCost(llvm::User const*, llvm::TargetTransformInfo::TargetCostKind) const /work/third_party/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h:411:12
#19 0x00007fb403b18388 llvm::InstructionCost::propagateState(llvm::InstructionCost const&) /work/third_party/llvm-project/llvm/include/llvm/Support/InstructionCost.h:57:19
#20 0x00007fb403b18388 llvm::InstructionCost::operator+=(llvm::InstructionCost const&) /work/third_party/llvm-project/llvm/include/llvm/Support/InstructionCost.h:100:5
#21 0x00007fb403b18388 llvm::CodeMetrics::analyzeBasicBlock(llvm::BasicBlock const*, llvm::TargetTransformInfo const&, llvm::SmallPtrSetImpl<llvm::Value const*> const&, bool) /work/third_party/llvm-project/llvm/lib/Analysis/CodeMetrics.cpp:180:14
#22 0x00007fb403265ebb llvm::FunctionSpecializer::run() /work/third_party/llvm-project/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp:0:0
#23 0x00007fb40325fbc3 runIPSCCP(llvm::Module&, llvm::DataLayout const&, llvm::AnalysisManager<llvm::Function>*, std::function<llvm::TargetLibraryInfo const& (llvm::Function&)>, std::function<llvm::TargetTransformInfo& (llvm::Function&)>, std::function<llvm::AssumptionCache& (llvm::Function&)>, std::function<llvm::DominatorTree& (llvm::Function&)>, std::function<llvm::BlockFrequencyInfo& (llvm::Function&)>, bool) /work/third_party/llvm-project/llvm/lib/Transforms/IPO/SCCP.cpp:165:5
#24 0x00007fb40325fbc3 llvm::IPSCCPPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /work/third_party/llvm-project/llvm/lib/Transforms/IPO/SCCP.cpp:402:8
#25 0x00007fb402ac373d llvm::detail::PassModel<llvm::Module, llvm::IPSCCPPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /work/third_party/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:5
#26 0x00007fb4041f9330 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /work/third_party/llvm-project/llvm/include/llvm/IR/PassManager.h:521:10
#27 0x00007fb3fe7ca5e0 llvm::SmallPtrSetImplBase::isSmall() const /work/third_party/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:195:33
```

We're going to revert locally. Especially given that this is impacting a target outside of RISCV, may I push a revert? We can try to generate a better repro asynchronously.

https://github.com/llvm/llvm-project/pull/67178


More information about the llvm-commits mailing list