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

[MIPS] Cannot select llvm.{min,max}imum.{f32,f64} #64207

Open
Urgau opened this issue Jul 28, 2023 · 4 comments
Open

[MIPS] Cannot select llvm.{min,max}imum.{f32,f64} #64207

Urgau opened this issue Jul 28, 2023 · 4 comments

Comments

@Urgau
Copy link

Urgau commented Jul 28, 2023

It seems that none of these intrinsics are currently working on MIPS:

  • llvm.minimum.f32
  • llvm.minimum.f64
  • llvm.maximum.f32
  • llvm.maximum.f64

Error output [godbolt]:

LLVM ERROR: Cannot select: 0x8787710: f32 = fmaximum 0x87875c0, 0x87876a0
  0x87875c0: f32,ch = CopyFromReg 0x86f0750, Register:f32 %0
    0x8787550: f32 = Register %0
  0x87876a0: f32,ch = CopyFromReg 0x86f0750, Register:f32 %1
    0x8787630: f32 = Register %1
In function: _ZN1a4test17hb60f9f6975710eeaE
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 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function '@_ZN1a4test17hb60f9f6975710eeaE'
 #0 0x0000000003066278 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3066278)
 #1 0x0000000003063e3c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fc3f21b8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fc3f1c7b00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fc3f1c5a859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000000000069cfa2 llvm::RISCVISAInfo::updateImplication() (.cold) RISCVISAInfo.cpp:0:0
 #6 0x0000000002e4f044 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e4f044)
 #7 0x0000000002e546d5 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e546d5)
 #8 0x0000000002e4c6a7 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e4c6a7)
 #9 0x0000000002e58f65 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e58f65)
#10 0x0000000002e5b9b9 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e5b9b9)
#11 0x0000000002e5e086 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#12 0x00000000013a2bcb llvm::MipsDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x13a2bcb)
#13 0x0000000002443820 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x00000000029263f2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x29263f2)
#15 0x0000000002926571 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2926571)
#16 0x00000000029280e0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x29280e0)
#17 0x0000000000766170 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#18 0x00000000006a7ce2 main (/opt/compiler-explorer/clang-trunk/bin/llc+0x6a7ce2)
#19 0x00007fc3f1c5c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#20 0x000000000075e0be _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x75e0be)

Similar to #53353 which was for x86_64

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 28, 2023

@llvm/issue-subscribers-backend-mips

@Cyanoxygen
Copy link
Contributor

There is a target independent implementation for llvm.fminimum and llvm.fmaximum intrinsic that is pending merge in #67301, shall we wait for that PR?

BTW I think a custom implementation for lowering FMIN and FMAX is feasible for MIPS R6, since it has native min.fmt and max.fmt FPU instructions.

@wzssyqa
Copy link
Contributor

wzssyqa commented Apr 3, 2024

@Cyanoxygen Please go ahead of this problem.

@Cyanoxygen
Copy link
Contributor

Sorry for the delay, I have to take rests because of a medical condition.

wzssyqa pushed a commit that referenced this issue Apr 27, 2024
- The behavior is similar to UCOMISD on x86, which is also used to
compare two fp values, specifically on handling of NaNs.
- Update related tests regarding this change.
- The further goal is to implement `llvm.minimum` and `llvm.maximum`
intrinsics for MIPS R6 and Pre-R6.

Part of #64207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants