Issue 244457
Summary Compiler crash related to __builtin_ia32_reduce_fmin_ph512
Labels new issue
Assignees
Reporter Gadal
    The following snippet appears to crash the compiler:

```
__attribute__((target("avx512fp16")))
auto _mm512_reduce_min_ph(_Float16 __attribute__((vector_size(64))) s) -> _Float16
{
    return __builtin_ia32_reduce_fmin_ph512(s);
}
```

Note that I've removed several of the attributes in LLVM's implementation of _mm512_reduce_min_ph; other permutations of those attributes still crash.

The error appears to have been introduced between 20.1.0 and 21.1.0. It is still present in 23.1.0.

This doesn't normally crash when #include-ing avx512fp16intrin.h, because `inline` appears to eliminate the code before instruction selection.

I guess AVX512FP16 isn't seeing much adoption :/

The output of the crash (in 23.1.0) is:

```
fatal error: error in backend: Cannot select: 0x1cf5aab0: v8f16 = pseudo_fmin nnan 0x1cf60360, 0x1cf60600, example.cpp:5:12
  0x1cf60360: v8f16 = pseudo_fmin nnan 0x1cf601a0, 0x1cf5a0a0, example.cpp:5:12
    0x1cf601a0: v8f16 = pseudo_fmin nnan 0x1cf59d20, 0x1cf60130, example.cpp:5:12
      0x1cf59d20: v8f16 = extract_subvector 0x1cf60210, Constant:i64<0>, example.cpp:5:12
 0x1cf60210: v16f16 = pseudo_fmin nnan 0x1cf5ffe0, 0x1cf60910, example.cpp:5:12
          0x1cf5ffe0: v16f16,ch = load<(dereferenceable load (s256) from %ir.2, align 64)> 0x1cf59d90, FrameIndex:i64<0>, undef:i64, example.cpp:5:12
          0x1cf60910: v16f16,ch = load<(dereferenceable load (s256) from %ir.2 + 32, basealign 64)> 0x1cf59d90, 0x1cf5a730, undef:i64, example.cpp:5:12
            0x1cf5a730: i64 = or disjoint FrameIndex:i64<0>, Constant:i64<32>, example.cpp:5:12
      0x1cf60130: v8f16 = extract_subvector 0x1cf60210, Constant:i64<8>, example.cpp:5:12
 0x1cf60210: v16f16 = pseudo_fmin nnan 0x1cf5ffe0, 0x1cf60910, example.cpp:5:12
          0x1cf5ffe0: v16f16,ch = load<(dereferenceable load (s256) from %ir.2, align 64)> 0x1cf59d90, FrameIndex:i64<0>, undef:i64, example.cpp:5:12
          0x1cf60910: v16f16,ch = load<(dereferenceable load (s256) from %ir.2 + 32, basealign 64)> 0x1cf59d90, 0x1cf5a730, undef:i64, example.cpp:5:12
            0x1cf5a730: i64 = or disjoint FrameIndex:i64<0>, Constant:i64<32>, example.cpp:5:12
    0x1cf5a0a0: v8f16 = bitcast 0x1cf60520, example.cpp:5:12
      0x1cf60520: v2f64 = X86ISD::VPERMILPI 0x1cf5ac00, TargetConstant:i8<1>, example.cpp:5:12
 0x1cf5ac00: v2f64 = bitcast 0x1cf601a0, example.cpp:5:12
 0x1cf601a0: v8f16 = pseudo_fmin nnan 0x1cf59d20, 0x1cf60130, example.cpp:5:12
            0x1cf59d20: v8f16 = extract_subvector 0x1cf60210, Constant:i64<0>, example.cpp:5:12
              0x1cf60210: v16f16 = pseudo_fmin nnan 0x1cf5ffe0, 0x1cf60910, example.cpp:5:12
 0x1cf5ffe0: v16f16,ch = load<(dereferenceable load (s256) from %ir.2, align 64)> 0x1cf59d90, FrameIndex:i64<0>, undef:i64, example.cpp:5:12
 0x1cf60910: v16f16,ch = load<(dereferenceable load (s256) from %ir.2 + 32, basealign 64)> 0x1cf59d90, 0x1cf5a730, undef:i64, example.cpp:5:12
 0x1cf5a730: i64 = or disjoint FrameIndex:i64<0>, Constant:i64<32>, example.cpp:5:12
            0x1cf60130: v8f16 = extract_subvector 0x1cf60210, Constant:i64<8>, example.cpp:5:12
 0x1cf60210: v16f16 = pseudo_fmin nnan 0x1cf5ffe0, 0x1cf60910, example.cpp:5:12
                0x1cf5ffe0: v16f16,ch = load<(dereferenceable load (s256) from %ir.2, align 64)> 0x1cf59d90, FrameIndex:i64<0>, undef:i64, example.cpp:5:12
                0x1cf60910: v16f16,ch = load<(dereferenceable load (s256) from %ir.2 + 32, basealign 64)> 0x1cf59d90, 0x1cf5a730, undef:i64, example.cpp:5:12
 0x1cf5a730: i64 = or disjoint FrameIndex:i64<0>, Constant:i64<32>, example.cpp:5:12
  0x1cf60600: v8f16 = bitcast 0x1cf5a420, example.cpp:5:12
    0x1cf5a420: v4f32 = X86ISD::MOVSHDUP 0x1cf5a570, example.cpp:5:12
      0x1cf5a570: v4f32 = bitcast 0x1cf60360, example.cpp:5:12
        0x1cf60360: v8f16 = pseudo_fmin nnan 0x1cf601a0, 0x1cf5a0a0, example.cpp:5:12
          0x1cf601a0: v8f16 = pseudo_fmin nnan 0x1cf59d20, 0x1cf60130, example.cpp:5:12
            0x1cf59d20: v8f16 = extract_subvector 0x1cf60210, Constant:i64<0>, example.cpp:5:12
 0x1cf60210: v16f16 = pseudo_fmin nnan 0x1cf5ffe0, 0x1cf60910, example.cpp:5:12
                0x1cf5ffe0: v16f16,ch = load<(dereferenceable load (s256) from %ir.2, align 64)> 0x1cf59d90, FrameIndex:i64<0>, undef:i64, example.cpp:5:12
                0x1cf60910: v16f16,ch = load<(dereferenceable load (s256) from %ir.2 + 32, basealign 64)> 0x1cf59d90, 0x1cf5a730, undef:i64, example.cpp:5:12
 0x1cf5a730: i64 = or disjoint FrameIndex:i64<0>, Constant:i64<32>, example.cpp:5:12
            0x1cf60130: v8f16 = extract_subvector 0x1cf60210, Constant:i64<8>, example.cpp:5:12
              0x1cf60210: v16f16 = pseudo_fmin nnan 0x1cf5ffe0, 0x1cf60910, example.cpp:5:12
 0x1cf5ffe0: v16f16,ch = load<(dereferenceable load (s256) from %ir.2, align 64)> 0x1cf59d90, FrameIndex:i64<0>, undef:i64, example.cpp:5:12
 0x1cf60910: v16f16,ch = load<(dereferenceable load (s256) from %ir.2 + 32, basealign 64)> 0x1cf59d90, 0x1cf5a730, undef:i64, example.cpp:5:12
 0x1cf5a730: i64 = or disjoint FrameIndex:i64<0>, Constant:i64<32>, example.cpp:5:12
          0x1cf5a0a0: v8f16 = bitcast 0x1cf60520, example.cpp:5:12
            0x1cf60520: v2f64 = X86ISD::VPERMILPI 0x1cf5ac00, TargetConstant:i8<1>, example.cpp:5:12
 0x1cf5ac00: v2f64 = bitcast 0x1cf601a0, example.cpp:5:12
 0x1cf601a0: v8f16 = pseudo_fmin nnan 0x1cf59d20, 0x1cf60130, example.cpp:5:12
                  0x1cf59d20: v8f16 = extract_subvector 0x1cf60210, Constant:i64<0>, example.cpp:5:12

 0x1cf60130: v8f16 = extract_subvector 0x1cf60210, Constant:i64<8>, example.cpp:5:12

In function: _Z20_mm512_reduce_min_phDv32_DF16_
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-23.1.0/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-15.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z20_mm512_reduce_min_phDv32_DF16_'
 #0 0x0000000003c063a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3c063a8)
 #1 0x0000000003c03cec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3c03cec)
 #2 0x0000000003b47e93 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3b47e93)
 #3 0x0000000003bfb63e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3bfb63e)
 #4 0x0000000000de9c5b LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x0000000003b505b3 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3b505b3)
 #6 0x00000000051e0fcd llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51e0fcd)
 #7 0x00000000051e8825 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int, unsigned char const*) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51e8825)
 #8 0x000000000285240a (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x00000000051e0334 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51e0334)
#10 0x00000000051ef902 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51ef902)
#11 0x00000000051f1b9f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51f1b9f)
#12 0x00000000051f35c5 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51f35c5)
#13 0x00000000051eeb01 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x51eeb01)
#14 0x0000000003052725 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3052725)
#15 0x0000000003567612 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3567612)
#16 0x0000000003567a21 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3567a21)
#17 0x00000000035684fa llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x35684fa)
#18 0x0000000003f8cbdf (anonymous namespace)::EmitAssemblyHelper::TimeCodegenPasses(llvm::function_ref<void ()>) (.isra.0) BackendUtil.cpp:0:0
#19 0x0000000003f9defa clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3f9defa)
#20 0x00000000045dc9d2 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x45dc9d2)
#21 0x00000000061de94c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x61de94c)
#22 0x00000000045dd405 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x45dd405)
#23 0x00000000049113e1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x49113e1)
#24 0x00000000048a2965 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x48a2965)
#25 0x00000000049e612b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x49e612b)
#26 0x0000000000debce8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0xdebce8)
#27 0x0000000000de3b7b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#28 0x0000000000de3c1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#29 0x0000000004658a19 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#30 0x0000000003b47d93 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x3b47d93)
#31 0x000000000465945d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#32 0x00000000046144a2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x46144a2)
#33 0x0000000004618755 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x4618755)
#34 0x00000000046235dc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0x46235dc)
#35 0x0000000000de86a1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0xde86a1)
#36 0x0000000000d0d14a main (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0xd0d14a)
#37 0x00007e689a82a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#38 0x00007e689a82a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#39 0x0000000000de3625 _start (/opt/compiler-explorer/clang-23.1.0/bin/clang+++0xde3625)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to