Issue 178272
Summary Assertion failure on vector FP to int conversions involving x86 SSE2 intrinsics
Labels new issue
Assignees
Reporter sairam2661
    **Fuzzer Generated Test**
**Reproducer**
https://godbolt.org/z/jn47x44zG

**Description**
An IR combining `SSE2` conversion intrinsics with vector `fptosi/fptoui` causes the optimizer to crash due to an invalid cast created during the intrinsic upgrade. Related: https://github.com/llvm/llvm-project/issues/153050

**Steps to reproduce**
- Test case, `input.ll`
```LLVM
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
define <8 x i32> @test(<8 x float> %0) #0 {
  %2 = tail call <8 x i32> @llvm.x86.sse2.cvtps2pi(<8 x float> %0) #2
  %3 = tail call <8 x i32> @llvm.x86.sse2.cvtps2pd(<8 x float> %0) #2
  %4 = fptosi <8 x float> %0 to <8 x i32>
  %5 = fptoui <8 x float> %0 to <8 x i32>
  %6 = shufflevector <8 x i32> %4, <8 x i32> %5, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
  ret <8 x i32> %6
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
attributes #1 = { nofree willreturn }
attributes #2 = { nofree nosync nounwind willreturn }
```

**Command**
```LLVM
opt -passes=default<O2> -S input.ll
```

**Output**
```LLVM
opt: /root/llvm-project/llvm/lib/IR/Instructions.cpp:3040: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::InsertPosition): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S --passes=default<O2> <source>
 #0 0x0000000005aa00f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5aa00f8)
 #1 0x0000000005a9cfd4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000700201842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007002018969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000700201842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007002018287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000070020182871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x0000700201839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000005787ae6 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5787ae6)
 #9 0x000000000401bcea llvm::IRBuilderBase::CreateFPExtFMF(llvm::Value*, llvm::Type*, llvm::FMFSource, llvm::Twine const&, llvm::MDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x401bcea)
#10 0x000000000563b0aa llvm::UpgradeIntrinsicCall(llvm::CallBase*, llvm::Function*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x563b0aa)
#11 0x0000000005422e95 llvm::LLParser::validateEndOfModule(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5422e95)
#12 0x000000000545b18b llvm::LLParser::Run(bool, llvm::function_ref<std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> (llvm::StringRef, llvm::StringRef)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x545b18b)
#13 0x0000000005403d47 parseAssemblyInto(llvm::MemoryBufferRef, llvm::Module*, llvm::ModuleSummaryIndex*, llvm::SMDiagnostic&, llvm::SlotMapping*, bool, llvm::function_ref<std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> (llvm::StringRef, llvm::StringRef)>, llvm::AsmParserContext*) Parser.cpp:0:0
#14 0x0000000005403ef1 llvm::parseAssembly(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::SlotMapping*, llvm::function_ref<std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> (llvm::StringRef, llvm::StringRef)>, llvm::AsmParserContext*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5403ef1)
#15 0x00000000053fed81 llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::ParserCallbacks, llvm::AsmParserContext*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53fed81)
#16 0x0000000005400fa4 llvm::parseIRFile(llvm::StringRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::ParserCallbacks, llvm::AsmParserContext*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5400fa4)
#17 0x0000000000960673 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x960673)
#18 0x0000700201829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#19 0x0000700201829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#20 0x0000000000959825 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x959825)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to