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

LLVM ERROR: Do not know how to expand this operator's operand! #92132

Open
DigOrDog opened this issue May 14, 2024 · 3 comments
Open

LLVM ERROR: Do not know how to expand this operator's operand! #92132

DigOrDog opened this issue May 14, 2024 · 3 comments
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well

Comments

@DigOrDog
Copy link

Description

The following code crashes x86_64 backend with "LLVM ERROR: Do not know how to expand this operator's operand!".

Minimal Reproduction

https://godbolt.org/z/KPeYhGx4o

Code

; ModuleID = 'Fuzzer input'
source_filename = "M"

@G = global <8 x i2> zeroinitializer
@G.1 = global i8 -128
@G.2 = global i16 0
@G.3 = global fp128 0xL00000000000000004004500000000000
@G.4 = global bfloat 0xR7F7F

define i8 @f(double %0, i16 %1, i8 %2, float %3, i8 %4) {
BB:
  %CastFPTrunc2 = fpext double %0 to ppc_fp128
  %LGV = load i8, ptr @G.1, align 1
  %RP = alloca i8, align 1
  %CastFPTrunc1 = fptrunc ppc_fp128 %CastFPTrunc2 to bfloat
  %L = load double, ptr %RP, align 8
  %Castbitcast = bitcast i16 %1 to <8 x i2>
  %5 = load i8, ptr %RP, align 1
  %CastFPTrunc = fpext double %L to fp128
  %CastExt = zext i8 %LGV to i16
  store <8 x i2> %Castbitcast, ptr @G, align 2
  store i16 %CastExt, ptr @G.2, align 2
  store fp128 %CastFPTrunc, ptr @G.3, align 16
  store ppc_fp128 %CastFPTrunc2, ptr %RP, align 16
  store bfloat %CastFPTrunc1, ptr @G.4, align 2
  ret i8 %5
}

Stack Trace

LLVM ERROR: Do not know how to expand this operator's operand!
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-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple x86_64 -O=0 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
 #0 0x00000000036a1558 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x36a1558)
 #1 0x000000000369eecc SignalHandler(int) Signals.cpp:0:0
 #2 0x0000729d9f042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000729d9f0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000729d9f042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000729d9f0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000000729932 llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
 #7 0x00000000035f9c18 (/opt/compiler-explorer/clang-trunk/bin/llc+0x35f9c18)
 #8 0x000000000356947f llvm::DAGTypeLegalizer::ExpandFloatOperand(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x356947f)
 #9 0x00000000035064b1 llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-trunk/bin/llc+0x35064b1)
#10 0x0000000003506911 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-trunk/bin/llc+0x3506911)
#11 0x000000000347d221 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x347d221)
#12 0x0000000003480068 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3480068)
#13 0x0000000003482849 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#14 0x0000000001c24011 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#15 0x00000000027d4c10 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x0000000002cf9742 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2cf9742)
#17 0x0000000002cf98c1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2cf98c1)
#18 0x0000000002cfb570 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2cfb570)
#19 0x000000000083e154 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x000000000073bb5e main (/opt/compiler-explorer/clang-trunk/bin/llc+0x73bb5e)
#21 0x0000729d9f029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x0000729d9f029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x0000000000835d9e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x835d9e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well and removed new issue labels May 14, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 14, 2024

@llvm/issue-subscribers-backend-x86

Author: None (DigOrDog)

# Description The following code crashes x86_64 backend with "LLVM ERROR: Do not know how to expand this operator's operand!".

Minimal Reproduction

https://godbolt.org/z/KPeYhGx4o

Code

; ModuleID = 'Fuzzer input'
source_filename = "M"

@<!-- -->G = global &lt;8 x i2&gt; zeroinitializer
@<!-- -->G.1 = global i8 -128
@<!-- -->G.2 = global i16 0
@<!-- -->G.3 = global fp128 0xL00000000000000004004500000000000
@<!-- -->G.4 = global bfloat 0xR7F7F

define i8 @<!-- -->f(double %0, i16 %1, i8 %2, float %3, i8 %4) {
BB:
  %CastFPTrunc2 = fpext double %0 to ppc_fp128
  %LGV = load i8, ptr @<!-- -->G.1, align 1
  %RP = alloca i8, align 1
  %CastFPTrunc1 = fptrunc ppc_fp128 %CastFPTrunc2 to bfloat
  %L = load double, ptr %RP, align 8
  %Castbitcast = bitcast i16 %1 to &lt;8 x i2&gt;
  %5 = load i8, ptr %RP, align 1
  %CastFPTrunc = fpext double %L to fp128
  %CastExt = zext i8 %LGV to i16
  store &lt;8 x i2&gt; %Castbitcast, ptr @<!-- -->G, align 2
  store i16 %CastExt, ptr @<!-- -->G.2, align 2
  store fp128 %CastFPTrunc, ptr @<!-- -->G.3, align 16
  store ppc_fp128 %CastFPTrunc2, ptr %RP, align 16
  store bfloat %CastFPTrunc1, ptr @<!-- -->G.4, align 2
  ret i8 %5
}

Stack Trace

LLVM ERROR: Do not know how to expand this operator's operand!
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-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple x86_64 -O=0 &lt;source&gt;
1.	Running pass 'Function Pass Manager' on module '&lt;source&gt;'.
2.	Running pass 'X86 DAG-&gt;DAG Instruction Selection' on function '@<!-- -->f'
 #<!-- -->0 0x00000000036a1558 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x36a1558)
 #<!-- -->1 0x000000000369eecc SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x0000729d9f042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x0000729d9f0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x0000729d9f042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x0000729d9f0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x0000000000729932 llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
 #<!-- -->7 0x00000000035f9c18 (/opt/compiler-explorer/clang-trunk/bin/llc+0x35f9c18)
 #<!-- -->8 0x000000000356947f llvm::DAGTypeLegalizer::ExpandFloatOperand(llvm::SDNode*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x356947f)
 #<!-- -->9 0x00000000035064b1 llvm::DAGTypeLegalizer::run() (/opt/compiler-explorer/clang-trunk/bin/llc+0x35064b1)
#<!-- -->10 0x0000000003506911 llvm::SelectionDAG::LegalizeTypes() (/opt/compiler-explorer/clang-trunk/bin/llc+0x3506911)
#<!-- -->11 0x000000000347d221 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x347d221)
#<!-- -->12 0x0000000003480068 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&amp;) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3480068)
#<!-- -->13 0x0000000003482849 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) (.part.0) SelectionDAGISel.cpp:0:0
#<!-- -->14 0x0000000001c24011 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) X86ISelDAGToDAG.cpp:0:0
#<!-- -->15 0x00000000027d4c10 llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (.part.0) MachineFunctionPass.cpp:0:0
#<!-- -->16 0x0000000002cf9742 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2cf9742)
#<!-- -->17 0x0000000002cf98c1 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2cf98c1)
#<!-- -->18 0x0000000002cfb570 llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2cfb570)
#<!-- -->19 0x000000000083e154 compileModule(char**, llvm::LLVMContext&amp;) llc.cpp:0:0
#<!-- -->20 0x000000000073bb5e main (/opt/compiler-explorer/clang-trunk/bin/llc+0x73bb5e)
#<!-- -->21 0x0000729d9f029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->22 0x0000729d9f029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->23 0x0000000000835d9e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x835d9e)
Program terminated with signal: SIGSEGV
Compiler returned: 139

@RKSimon
Copy link
Collaborator

RKSimon commented May 14, 2024

Looks like we're missing fallback for fp_to_bf16

@phoebewang
Copy link
Contributor

The IR looks problematic to me. I don't think X86 backend is able to handle ppc_fp128 correctly.

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] llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

No branches or pull requests

5 participants