<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/85643>85643</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] LLVM ERROR: Cannot select: 0xb03f0e0: f128 = fminimum contract 0xb045540, 0xb040de0
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Reproducible on Godbolt:
https://godbolt.org/z/vE97oe846

Reproducer:
```console
$ cat test.f90
subroutine s1(r, i)
  real, dimension(i:i,i:i) :: r
 real :: r1
  real(16) :: r2
  integer :: i, k

!$omp parallel
!$omp do firstprivate(r), &
!$omp reduction(min:r1,r2)
 do k=i,i
        r1 = min(r(k,k),r1)
      end do
!$omp end do
!$omp end parallel

end subroutine
```

Stack dump:
```console
LLVM ERROR: Cannot select: 0xb03f0e0: f128 = fminimum contract 0xb045540, 0xb040de0
  0xb045540: f128,ch = load<(load (s128) from %ir.loadgep_6)> 0xb038be0, 0xb03ecf0, undef:i64
    0xb03ecf0: i64,ch = CopyFromReg 0xafa54b0, Register:i64 %26
      0xb040590: i64 = Register %26
    0xb03f2a0: i64 = undef
  0xb040de0: f128,ch = load<(dereferenceable load (s128) from %ir.4)> 0xb038be0, FrameIndex:i64<2>, undef:i64
    0xb040ec0: i64 = FrameIndex<2>
    0xb03f2a0: i64 = undef
In function: s1_..omp_par
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-llvmflang-trunk-20240318/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -S -fopenmp -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
1.      Running pass 'Function Pass Manager' on module 'FIRModule'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@s1_..omp_par'
 #0 0x00000000036e4a78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x36e4a78)
 #1 0x00000000036e23ec SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fc1fca42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007fc1fca969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007fc1fca42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007fc1fca287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000001d94d7a llvm::RISCVISAInfo::updateCombination() (.cold) RISCVISAInfo.cpp:0:0
 #7 0x000000000573ad84 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x573ad84)
 #8 0x0000000005740f05 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x5740f05)
 #9 0x0000000003316b7d (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
#10 0x000000000573813f llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x573813f)
#11 0x0000000005745b25 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x5745b25)
#12 0x00000000057487d8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x57487d8)
#13 0x000000000574afa9 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#14 0x0000000003320c61 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#15 0x0000000005befc40 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x0000000007ac06e2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x7ac06e2)
#17 0x0000000007ac0861 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x7ac0861)
#18 0x0000000007ac2480 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x7ac2480)
#19 0x0000000003a51bd8 Fortran::frontend::CodeGenAction::executeAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x3a51bd8)
#20 0x000000000372890d Fortran::frontend::FrontendAction::execute() (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x372890d)
#21 0x0000000003718196 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x3718196)
#22 0x000000000372e63d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x372e63d)
#23 0x0000000001ed17b8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x1ed17b8)
#24 0x0000000001dd6aad main (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x1dd6aad)
#25 0x00007fc1fca29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#26 0x00007fc1fca29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#27 0x0000000001ed071e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240318/bin/flang-new+0x1ed071e)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git c0d03d28c58f3016eb25ce8d1160e11183d01735)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WVtv2zrW_TXMCyGDou4PeXDtOF-A069BUhx0ngKK3HI4kUiBolJnfv2AlBxbqptLcTxBm5iXvfdam4tXs66TWwVwiZIvKFlfsN4-anP5FDBj9M_uotTi5fIOWqNFz2VZA9YKX2tR6tqiaInIGpHlo7Vt50p0g-hmO7QutNkiuvkPopvnqyLTkMfp0H34vXcK5tUPSsnwj2vV6RrGWhpjziy20NlFVZChtutLo3srFeAuRDQ3iK6wRLQYmjE2wGpXJ2QDqpNaIZpLFC0loqvxb4Fd6GiJzWjkbF7rwqmnPEyPLei-VSoLWzD7BucePx0TRTRENNZNi1tmWF1DPa8XGlfSdLY18plZGNgUzhGi6byzAdFzO_BppELR0oSIrgw9cBcaP6FoPTAdYQ4_JsQoWmNn54PkT4iunoZgzk1x3B2UwELP4_--dkbP_3b1h6GaDfNxx3vL-BMWfdO-I4e__vr7K766u_t259K9YkppizuogTtBYrIrSVQRIK5QhTT3hKtGKtn0DeZaWcO49f3iJImJS7MvEAFkT__QOnpBdMUfvataM4GiFaK5-4QRzTvfXuDK6AYjmkizcE1baB-cZFB0NaDKS3iNFgGvfKFXAionxzQ-5P7QwykqjQ_RV7p92Rjd3MEWkx2rWBKX3s8dbGVn_WSSaexg7KUzDOZAMSn2Lr23vdG8-5BEyiadB6THCfIZeyNBAgxUYEBxYG7peCNh8alEbQxr4EYJ2I0JilYURVdvpi0mwCewj50M5h-meaNw1athskVL3IUPi4Vu2oeWjQvG7V9Xy_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