Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x86_64] Cannot select sint_to_fp for v8bf16 when targeting sapphirerapids / znver4 CPU #64440

Closed
HazyFish opened this issue Aug 4, 2023 · 3 comments
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@HazyFish
Copy link
Contributor

HazyFish commented Aug 4, 2023

Description

When casting i16 vector to bf16 vector using uitofp / sitofp, x86_64 backend will crash with error Cannot select: t17: v8bf16 = sint_to_fp t26 when targeting Intel sapphirerapids or AMD znver4 CPU.

The problem doesn't exist when casting i16 vector to half vector.
The problem doesn't exist when targeting znver3, alderlake, or raptorlake CPUs, or when CPU is not specified.

Minimal Repoduction

https://godbolt.org/z/MKEb6rjns

Code

define void @f(ptr %0, ptr %1) {
  %vi = load <4 x i16>, ptr %0
  %vf = uitofp <4 x i16> %vi to <4 x bfloat>
  store <4 x bfloat> %vf, ptr %1
  ret void
}

Stack Trace

LLVM ERROR: Cannot select: t17: v8bf16 = sint_to_fp t26
  t26: v8i32 = insert_subvector undef:v8i32, t14, Constant:i64<0>
    t25: v8i32 = undef
    t14: v4i32,ch = load<(load (s64) from %ir.0), zext from v4i16> t0, t2, undef:i64
      t2: i64,ch = CopyFromReg t0, Register:i64 %0
        t1: i64 = Register %0
      t6: i64 = undef
    t19: i64 = Constant<0>
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 -mcpu=sapphirerapids <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
 #0 0x0000000003398418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3398418)
 #1 0x0000000003395d0c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f51ad6d9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f51ad19c00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f51ad17b859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x0000000000695331 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x695331)
 #6 0x0000000003162a4d llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3162a4d)
 #7 0x0000000003164859 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3164859)
 #8 0x0000000001b7f921 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x000000000315f35f llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x315f35f)
#10 0x000000000316c789 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x316c789)
#11 0x000000000316ff88 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x316ff88)
#12 0x0000000003171c82 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000000001b894bc (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000000002680049 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000002bf8bb9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8bb9)
#16 0x0000000002bf8df1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8df1)
#17 0x0000000002bf9612 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf9612)
#18 0x000000000075e092 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x000000000069a7e6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x69a7e6)
#20 0x00007f51ad17d083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#21 0x0000000000754a4e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x754a4e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@HazyFish
Copy link
Contributor Author

HazyFish commented Aug 4, 2023

@DataCorrupted

@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Aug 4, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 4, 2023

@llvm/issue-subscribers-backend-x86

uilnauyisDP added a commit to SecurityLab-UCD/LLVM-fuzzing-trophies that referenced this issue Sep 13, 2023
@HazyFish
Copy link
Contributor Author

Fixed in 6688701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

3 participants