[llvm] [RISCV] Cost ordered bf16/f16 w/ zvfhmin reductions as invalid (PR #114250)
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 11:03:34 PDT 2025
hvdijk wrote:
This change causes `getVectorElement()` to be called without checking that the type is a vector, resulting in an assertion failure that can be seen with this PR's `reduce-fadd.ll` when using just `-mattr=+v`:
```console
$ bin/opt -mtriple=riscv64 -mattr=+v '-passes=print<cost-model>' -cost-kind=throughput -disable-output /home/harald/llvm-project/20.x/llvm/test/Analysis/CostModel/RISCV/reduce-fadd.ll
Printing analysis 'Cost Model Analysis' for function 'reduce_fadd_bfloat':
opt: /home/harald/llvm-project/20.x/llvm/include/llvm/CodeGenTypes/MachineValueType.h:272: llvm::MVT llvm::MVT::getVectorElementType() const: Assertion `VT != INVALID_SIMPLE_VALUE_TYPE && "Not a vector MVT!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: bin/opt -mtriple=riscv64 -mattr=+v -passes=print<cost-model> -cost-kind=throughput -disable-output /home/harald/llvm-project/20.x/llvm/test/Analysis/CostModel/RISCV/reduce-fadd.ll
1. Running pass "function(print<cost-model>)" on module "/home/harald/llvm-project/20.x/llvm/test/Analysis/CostModel/RISCV/reduce-fadd.ll"
2. Running pass "print<cost-model>" on function "reduce_fadd_bfloat"
#0 0x000073a66c664d93 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/harald/llvm-project/20.x/llvm/lib/Support/Unix/Signals.inc:723:22
#1 0x000073a66c6650de PrintStackTraceSignalHandler(void*) /home/harald/llvm-project/20.x/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x000073a66c663da2 llvm::sys::RunSignalHandlers() /home/harald/llvm-project/20.x/llvm/lib/Support/Signals.cpp:105:20
#3 0x000073a66c66412b SignalHandler(int) /home/harald/llvm-project/20.x/llvm/lib/Support/Unix/Signals.inc:403:31
#4 0x000073a66ae45810 (/lib/x86_64-linux-gnu/libc.so.6+0x45810)
#5 0x000073a66aea50bc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa50bc)
#6 0x000073a66ae456de raise (/lib/x86_64-linux-gnu/libc.so.6+0x456de)
#7 0x000073a66ae288cd abort (/lib/x86_64-linux-gnu/libc.so.6+0x288cd)
#8 0x000073a66ae28830 __assert_perror_fail (/lib/x86_64-linux-gnu/libc.so.6+0x28830)
#9 0x000073a66ca38a7e llvm::LLT::getAddressSpace() const /home/harald/llvm-project/20.x/llvm/include/llvm/CodeGenTypes/LowLevelType.h:280:22
#10 0x000073a66faa1d62 llvm::RISCVTTIImpl::getArithmeticReductionCost(unsigned int, llvm::VectorType*, std::optional<llvm::FastMathFlags>, llvm::TargetTransformInfo::TargetCostKind) /home/harald/llvm-project/20.x/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp:1588:0
#11 0x000073a66faa7890 llvm::BasicTTIImplBase<llvm::RISCVTTIImpl>::getTypeBasedIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /home/harald/llvm-project/20.x/llvm/include/llvm/CodeGen/BasicTTIImpl.h:2129:0
#12 0x000073a66faaa4e5 llvm::BasicTTIImplBase<llvm::RISCVTTIImpl>::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /home/harald/llvm-project/20.x/llvm/include/llvm/CodeGen/BasicTTIImpl.h:1712:0
#13 0x000073a66faa2f22 llvm::RISCVTTIImpl::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) /home/harald/llvm-project/20.x/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp:1207:0
#14 0x000073a66fa99949 llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) /home/harald/llvm-project/20.x/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:1254:0
#15 0x000073a66fa9a96f llvm::TargetTransformInfo::Model<llvm::RISCVTTIImpl>::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) /home/harald/llvm-project/20.x/llvm/include/llvm/Analysis/TargetTransformInfo.h:2295:0
#16 0x000073a66de9700f llvm::TargetTransformInfo::getInstructionCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) const /home/harald/llvm-project/20.x/llvm/lib/Analysis/TargetTransformInfo.cpp:275:3
#17 0x000073a66c9e519e llvm::TargetTransformInfo::getInstructionCost(llvm::User const*, llvm::TargetTransformInfo::TargetCostKind) const /home/harald/llvm-project/20.x/llvm/include/llvm/Analysis/TargetTransformInfo.h:415:30
#18 0x000073a66dca482b llvm::CostModelPrinterPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/harald/llvm-project/20.x/llvm/lib/Analysis/CostModel.cpp:66:14
#19 0x000073a67021627d llvm::detail::PassModel<llvm::Function, llvm::CostModelPrinterPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/harald/llvm-project/20.x/llvm/include/llvm/IR/PassManagerInternal.h:91:3
#20 0x000073a66c8248cf llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/harald/llvm-project/20.x/llvm/include/llvm/IR/PassManagerImpl.h:85:18
#21 0x000073a66ec2e2a7 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/harald/llvm-project/20.x/llvm/include/llvm/IR/PassManagerInternal.h:91:3
#22 0x000073a66c818f89 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/harald/llvm-project/20.x/llvm/lib/IR/PassManager.cpp:129:41
#23 0x000073a66ec2e301 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/harald/llvm-project/20.x/llvm/include/llvm/IR/PassManagerInternal.h:91:3
#24 0x000073a66c824667 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/harald/llvm-project/20.x/llvm/include/llvm/IR/PassManagerImpl.h:85:18
#25 0x000060a6dcb6449a llvm::SmallPtrSetImpl<llvm::AnalysisKey*>::~SmallPtrSetImpl() /home/harald/llvm-project/20.x/llvm/include/llvm/ADT/SmallPtrSet.h:346:7
#26 0x000060a6dcb6449a llvm::SmallPtrSet<llvm::AnalysisKey*, 2u>::~SmallPtrSet() /home/harald/llvm-project/20.x/llvm/include/llvm/ADT/SmallPtrSet.h:502:7
#27 0x000060a6dcb6449a llvm::PreservedAnalyses::~PreservedAnalyses() /home/harald/llvm-project/20.x/llvm/include/llvm/IR/Analysis.h:111:7
#28 0x000060a6dcb6449a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /home/harald/llvm-project/20.x/llvm/tools/opt/NewPMDriver.cpp:541:10
#29 0x000060a6dcb53507 optMain /home/harald/llvm-project/20.x/llvm/tools/opt/optdriver.cpp:745:16
#30 0x000060a6dcb50460 main /home/harald/llvm-project/20.x/llvm/tools/opt/opt.cpp:25:67
#31 0x000073a66ae2a338 (/lib/x86_64-linux-gnu/libc.so.6+0x2a338)
#32 0x000073a66ae2a3fb __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a3fb)
#33 0x000060a6dcb50385 _start (bin/opt+0x1c385)
Aborted
```
Before this PR, this never reached the `LT.second.getVectorElementType()` call, so things worked, possibly by accident.
Could you take a look? Should I open an issue for this?
https://github.com/llvm/llvm-project/pull/114250
More information about the llvm-commits
mailing list