LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 49215 - Regression (12.0) Assertion `ValTy->isFPOrFPVectorTy() && "Expected float point or integer vector type."' failed
Summary: Regression (12.0) Assertion `ValTy->isFPOrFPVectorTy() && "Expected float poi...
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: X86 (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Sanjay Patel
URL:
Keywords:
Depends on:
Blocks: release-12.0.0
  Show dependency tree
 
Reported: 2021-02-16 21:47 PST by Bernhard Rosenkraenzer
Modified: 2021-02-22 11:49 PST (History)
6 users (show)

See Also:
Fixed By Commit(s): 5b250a27ec78 a3545a0b0777


Attachments
Reduced test case (409 bytes, text/x-c++src)
2021-02-16 21:47 PST, Bernhard Rosenkraenzer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Rosenkraenzer 2021-02-16 21:47:31 PST
Created attachment 24545 [details]
Reduced test case

Building the attached test case with clang [today's 12.0 branch] with SSE4.2 enabled (-msse4.2 or -march=znver1 or any other -march= that enables sse4.2) results in

$ clang++ -c test.ii -o test.o -O2 -msse4.2
clang++: /home/bero/abf/llvm/BUILD/llvm-project-release-12.x/llvm/lib/Target/X86/X86TargetTransformInfo.cpp:3717: int llvm::X86TTIImpl::getMinMaxReductionCost(llvm::VectorType *, llvm::VectorType *, bool, bool, TTI::TargetCostKind): Assertion `ValTy->isFPOrFPVectorTy() && "Expected float point or integer vector type."' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++ -c test.ii -o test.o -O2 -march=znver1
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x00007f4c35702ce1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib64/libLLVMSupport.so.12.0+0x235ce1)
 #1 0x00007f4c35702fbd (/usr/lib64/libLLVMSupport.so.12.0+0x235fbd)
 #2 0x00007f4c3570090a llvm::sys::RunSignalHandlers() (/usr/lib64/libLLVMSupport.so.12.0+0x23390a)
 #3 0x00007f4c35701efb llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib64/libLLVMSupport.so.12.0+0x234efb)
 #4 0x00007f4c35612035 (/usr/lib64/libLLVMSupport.so.12.0+0x145035)
 #5 0x00007f4c35612245 (/usr/lib64/libLLVMSupport.so.12.0+0x145245)
 #6 0x00007f4c351399c0 __restore_rt (/lib64/libc.so.6+0x409c0)
 #7 0x00007f4c3513993f raise (/lib64/libc.so.6+0x4093f)
 #8 0x00007f4c3511f538 abort (/lib64/libc.so.6+0x26538)
 #9 0x00007f4c3511f421 _nl_load_domain.cold (/lib64/libc.so.6+0x26421)
#10 0x00007f4c35130c82 (/lib64/libc.so.6+0x37c82)
#11 0x00007f4c3a56d991 llvm::X86TTIImpl::getMinMaxReductionCost(llvm::VectorType*, llvm::VectorType*, bool, bool, llvm::TargetTransformInfo::TargetCostKind) (/usr/lib64/libLLVMX86CodeGen.so.12.0+0x530991)
#12 0x00007f4c3a573a83 (/usr/lib64/libLLVMX86CodeGen.so.12.0+0x536a83)
#13 0x00007f4c3a56a012 (/usr/lib64/libLLVMX86CodeGen.so.12.0+0x52d012)
#14 0x00007f4c3a56ace6 llvm::X86TTIImpl::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) (/usr/lib64/libLLVMX86CodeGen.so.12.0+0x52dce6)
#15 0x00007f4c3a56341b (/usr/lib64/libLLVMX86CodeGen.so.12.0+0x52641b)
#16 0x00007f4c3a560047 (/usr/lib64/libLLVMX86CodeGen.so.12.0+0x523047)
#17 0x00007f4c3687879f llvm::TargetTransformInfo::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>, llvm::TargetTransformInfo::TargetCostKind) const (/usr/lib64/libLLVMAnalysis.so.12.0+0x5ab79f)
#18 0x00007f4c365e7269 (/usr/lib64/libLLVMAnalysis.so.12.0+0x31a269)
#19 0x00007f4c365e6d1a llvm::CodeMetrics::analyzeBasicBlock(llvm::BasicBlock const*, llvm::TargetTransformInfo const&, llvm::SmallPtrSetImpl<llvm::Value const*> const&, bool) (/usr/lib64/libLLVMAnalysis.so.12.0+0x319d1a)
#20 0x00007f4c378941c5 (/usr/lib64/libLLVMScalarOpts.so.12.0+0x3541c5)
#21 0x00007f4c37894eef llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/lib64/libLLVMScalarOpts.so.12.0+0x354eef)
#22 0x00007f4c349b8d3f (/usr/lib64/libLLVMPasses.so.12.0+0x181d3f)
#23 0x00007f4c35c73456 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/lib64/libLLVMCore.so.12.0+0x42c456)
#24 0x00007f4c3c7c3c3f (/usr/lib64/libLLVMAMDGPUCodeGen.so.12.0+0x56ec3f)
#25 0x00007f4c35c78ab9 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib64/libLLVMCore.so.12.0+0x431ab9)
#26 0x00007f4c3c7c399f (/usr/lib64/libLLVMAMDGPUCodeGen.so.12.0+0x56e99f)
#27 0x00007f4c35c71ad9 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib64/libLLVMCore.so.12.0+0x42aad9)
#28 0x00007f4c38d28922 (/usr/lib64/libclangCodeGen.so.12.0+0x2a1922)
#29 0x00007f4c38d21037 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/lib64/libclangCodeGen.so.12.0+0x29a037)
#30 0x00007f4c3908b60f (/usr/lib64/libclangCodeGen.so.12.0+0x60460f)
#31 0x00007f4c32f22515 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib64/libclangParse.so.12.0+0x70515)
#32 0x00007f4c3731744f clang::ASTFrontendAction::ExecuteAction() (/usr/lib64/libclangFrontend.so.12.0+0x1ab44f)
#33 0x00007f4c39086200 clang::CodeGenAction::ExecuteAction() (/usr/lib64/libclangCodeGen.so.12.0+0x5ff200)
#34 0x00007f4c37316b16 clang::FrontendAction::Execute() (/usr/lib64/libclangFrontend.so.12.0+0x1aab16)
#35 0x00007f4c3727c5aa clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib64/libclangFrontend.so.12.0+0x1105aa)
#36 0x00007f4c39bf1c38 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib64/libclangFrontendTool.so.12.0+0x5c38)
#37 0x000000000021957f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-12+0x21957f)
#38 0x0000000000216e2f (/usr/bin/clang-12+0x216e2f)
#39 0x00007f4c36fbd004 (/usr/lib64/libclangDriver.so.12.0+0x115004)
#40 0x00007f4c35611f1a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib64/libLLVMSupport.so.12.0+0x144f1a)
#41 0x00007f4c36fbc34f clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/usr/lib64/libclangDriver.so.12.0+0x11434f)
#42 0x00007f4c36f7d5ac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/usr/lib64/libclangDriver.so.12.0+0xd55ac)
#43 0x00007f4c36f7d8ba clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/usr/lib64/libclangDriver.so.12.0+0xd58ba)
#44 0x00007f4c36f99cc1 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/usr/lib64/libclangDriver.so.12.0+0xf1cc1)
#45 0x0000000000215f94 main (/usr/bin/clang-12+0x215f94)
#46 0x00007f4c3512156d __libc_start_main (/lib64/libc.so.6+0x2856d)
#47 0x0000000000212a6a _start (/usr/bin/clang-12+0x212a6a)
clang-12: error: clang frontend command failed with exit code 134 (use -v to see invocation)
OpenMandriva 12.0.0-0.20210216.1 clang version 12.0.0 (/home/bero/abf/llvm/BUILD/llvm-project-release-12.x/clang e8879607869c0621936fcd3af4b973dea59e7e9b)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-12: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
Comment 1 Sanjay Patel 2021-02-17 08:31:24 PST
The assert is in the x86 cost model. I'll take a look.
Comment 2 Sanjay Patel 2021-02-17 08:48:22 PST
We created a reduction of a vector of pointers:
define void @reduce_vector_pointers(<16 x i32*> %x) {
  %r0 = call i32* @llvm.vector.reduce.umin.v16p0i32(<16 x i32*> %x)
  ret void
}


But that's apparently not allowed by LangRef:
https://llvm.org/docs/LangRef.html#llvm-vector-reduce-umin-intrinsic
Comment 3 Sanjay Patel 2021-02-17 11:50:11 PST
I think we need to constrict our reduction definitions as a first step.

These all pass the IR verifier currently...

FP min of pointers:
  %r0 = call i32* @llvm.vector.reduce.fmin.v16p0i32(<16 x i32*> %x)

FP min of integers:
  %r0 = call i32 @llvm.vector.reduce.fmin.v16i32(<16 x i32> %x)

Integer umin of float:
  %r0 = call float @llvm.vector.reduce.umin.v16f32(<16 x float> %x)
Comment 4 Sanjay Patel 2021-02-17 14:42:53 PST
(In reply to Sanjay Patel from comment #3)
> I think we need to constrict our reduction definitions as a first step.

Proposal:
https://reviews.llvm.org/D96904
Comment 5 Sanjay Patel 2021-02-19 11:14:26 PST
We should avoid crashing with:
https://reviews.llvm.org/rG5b250a27ec78
https://reviews.llvm.org/D97047
Comment 6 Simon Pilgrim 2021-02-20 03:02:38 PST
@spatel The subject says this is a 12.0 regression - what would be the cherry pick list to get this into the 12.x branch?
Comment 7 Sanjay Patel 2021-02-20 05:34:11 PST
(In reply to Simon Pilgrim from comment #6)
> @spatel The subject says this is a 12.0 regression - what would be the
> cherry pick list to get this into the 12.x branch?

Ah - it's just this one:
https://reviews.llvm.org/rG5b250a27ec78

(The verifier improvement I was working on is independent, and I haven't pushed it yet.)
Comment 8 Tom Stellard 2021-02-22 11:49:56 PST
Merged: a3545a0b0777