Bug 278305 - clang crashes: fatal error: error in backend: Cannot select: t71: v32bf16 = insert_subvector t67, t64, Constant:i32<16> (on the port misc/ncnn)
Summary: clang crashes: fatal error: error in backend: Cannot select: t71: v32bf16 = i...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 15.0-CURRENT
Hardware: i386 Any
: --- Affects Many People
Assignee: freebsd-toolchain (Nobody)
URL: https://pkg-status.freebsd.org/beefy1...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-11 07:51 UTC by Yuri Victorovich
Modified: 2024-04-20 14:12 UTC (History)
2 users (show)

See Also:
dim: mfc-stable14+
dim: mfc-stable13+


Attachments
reproduction source saved by compiler (882.10 KB, application/x-gzip)
2024-04-11 17:39 UTC, John F. Carr
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2024-04-11 07:51:49 UTC
This port wasn't updated recently, but clang now crashes on 15-CURRENT i386:

fatal error: error in backend: Cannot select: t71: v32bf16 = insert_subvector t67, t64, Constant:i32<16>
  t67: v32bf16 = insert_subvector undef:v32bf16, t65, Constant:i32<0>
    t66: v32bf16 = undef
    t65: v16bf16 = X86ISD::CVTNEPS2BF16 nnan ninf nsz arcp contract afn reassoc t5
      t5: v16f32,ch = load<(load (s512) from %ir.ptr.0194, align 1, !tbaa !30)> t0, t2, undef:i32
        t2: i32,ch = CopyFromReg t0, Register:i32 %15
          t1: i32 = Register %15
        t4: i32 = undef
    t60: i32 = Constant<0>
  t64: v16bf16 = X86ISD::CVTNEPS2BF16 nnan ninf nsz arcp contract afn reassoc t8
    t8: v16f32,ch = load<(load (s512) from %ir.scevgep, align 1, !tbaa !30)> t0, t7, undef:i32
      t7: i32 = add t2, Constant:i32<64>
        t2: i32,ch = CopyFromReg t0, Register:i32 %15
          t1: i32 = Register %15
        t6: i32 = Constant<64>
      t4: i32 = undef
  t70: i32 = Constant<16>
In function: _ZN4ncnnL21cast_fp32_to_bf16_sseERKNS_3MatERS0_RKNS_6OptionE.omp_outlined
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /usr/bin/c++ -I/wrkdirs/usr/ports/misc/ncnn/work/ncnn-20240102/src/layer/x86 -I/wrkdirs/usr/ports/misc/ncnn/work/ncnn-20240102/src -I/wrkdirs/usr/ports/misc/ncnn/work/.build/src -I/wrkdirs/usr/ports/misc/ncnn/work/ncnn-20240102/src/layer -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DNDEBUG -fPIC -DNCNN_STATIC_DEFINE -Wall -Wextra -Wno-unused-function -Ofast -ffast-math -fvisibility=hidden -fvisibility-inlines-hidden -msse2 -msse -fopenmp=libomp -pthread -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl -mfma -mf16c -mavx512bf16 -MD -MT src/CMakeFiles/ncnn.dir/layer/x86/cast_x86_avx512bf16.cpp.o -MF src/CMakeFiles/ncnn.dir/layer/x86/cast_x86_avx512bf16.cpp.o.d -o src/CMakeFiles/ncnn.dir/layer/x86/cast_x86_avx512bf16.cpp.o -c /wrkdirs/usr/ports/misc/ncnn/work/ncnn-20240102/src/layer/x86/cast_x86_avx512bf16.cpp
Comment 1 John F. Carr 2024-04-11 17:39:07 UTC
Created attachment 249906 [details]
reproduction source saved by compiler
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2024-04-11 18:32:32 UTC
I got a local repro here, and while I *thought* this was fixed by https://github.com/llvm/llvm-project/commit/2e4e04c59043, unfortunately it is not the case. I am still attempting to reduce the test case, but it is going very slowly, still at 231056 lines.
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-04-11 21:18:19 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=78d3648e73d11c5a4dbcc0392907f0723bf1df1c

commit 78d3648e73d11c5a4dbcc0392907f0723bf1df1c
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-11 21:12:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-11 21:16:36 +0000

    Merge commit 55c466da2f2f from llvm-project (by Benjamin Kramer):

      [X86][AVX512BF16] Add a few missing insert/extract patterns

      These are really the same as the f16 (and i16) instructions, but we need
      them for any type that can occur.

    Merge commit 2e4e04c59043 from llvm-project (by Phoebe Wang):

      [X86][BF16] Do not lower to VCVTNEPS2BF16 without AVX512VL (#86395)

      Fixes: #86305

    These should fix "fatal error: error in backend: Cannot select: t71:
    v32bf16 = insert_subvector t67, t64, Constant:i32<16>" when building the
    misc/ncnn port.

    PR:             278305
    Reported by:    yuri
    MFC after:      1 month

 contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp |  7 +++++--
 contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td   | 12 ++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2024-04-11 21:19:38 UTC
Eh sorry, the MFC after: 1 month was the usual period for the clang 18 merge, but it is very likely that I will expedite it for the upcoming 14.1 slush.
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-04-20 10:33:24 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a3549d8d4dbf7f6e30bcbdc18cf6dda2bd09d39b

commit a3549d8d4dbf7f6e30bcbdc18cf6dda2bd09d39b
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-11 21:12:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-20 10:03:25 +0000

    Merge commit 55c466da2f2f from llvm-project (by Benjamin Kramer):

      [X86][AVX512BF16] Add a few missing insert/extract patterns

      These are really the same as the f16 (and i16) instructions, but we need
      them for any type that can occur.

    Merge commit 2e4e04c59043 from llvm-project (by Phoebe Wang):

      [X86][BF16] Do not lower to VCVTNEPS2BF16 without AVX512VL (#86395)

      Fixes: #86305

    These should fix "fatal error: error in backend: Cannot select: t71:
    v32bf16 = insert_subvector t67, t64, Constant:i32<16>" when building the
    misc/ncnn port.

    PR:             278305
    Reported by:    yuri
    MFC after:      1 month

    (cherry picked from commit 78d3648e73d11c5a4dbcc0392907f0723bf1df1c)

 contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp |  7 +++++--
 contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td   | 12 ++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-04-20 10:36:28 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ac652ee7fbdcf0651f23bc09455f7705980fd232

commit ac652ee7fbdcf0651f23bc09455f7705980fd232
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-04-11 21:12:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-04-20 10:29:10 +0000

    Merge commit 55c466da2f2f from llvm-project (by Benjamin Kramer):

      [X86][AVX512BF16] Add a few missing insert/extract patterns

      These are really the same as the f16 (and i16) instructions, but we need
      them for any type that can occur.

    Merge commit 2e4e04c59043 from llvm-project (by Phoebe Wang):

      [X86][BF16] Do not lower to VCVTNEPS2BF16 without AVX512VL (#86395)

      Fixes: #86305

    These should fix "fatal error: error in backend: Cannot select: t71:
    v32bf16 = insert_subvector t67, t64, Constant:i32<16>" when building the
    misc/ncnn port.

    PR:             278305
    Reported by:    yuri
    MFC after:      1 month

    (cherry picked from commit 78d3648e73d11c5a4dbcc0392907f0723bf1df1c)

 contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp |  7 +++++--
 contrib/llvm-project/llvm/lib/Target/X86/X86InstrAVX512.td   | 12 ++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)