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

    <tr>
        <th>Summary</th>
        <td>
            llvm::SelectionDAGISel -- cannot select ch = PPCISD::STBRX<(store (s64) into %ir.0, !tbaa !49)>
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ltertan
      </td>
    </tr>
</table>

<pre>
    **Compile options:**

clang --target=ppc64 -mcpu=a2 -O2 example.cpp

**example.cpp**
```
typedef long unsigned int UINT64;
typedef unsigned short UINT16;

typedef struct {
    unsigned long num;
    unsigned short val[4];
} Mystruct;

int myFunc (Mystruct *device)
{
    device->num = (UINT64 )( ((UINT64)
    (UINT16)((((device->val[0]) & 0x00ff) << 8) | (((device->val[0]) & 0xff00) >> 8))) |
    ((UINT64)
    (UINT16)((((device->val[1]) & 0x00ff) << 8) | (((device->val[1]) & 0xff00) >> 8)) << 16) |
    ((UINT64)
    (UINT16)((((device->val[2]) & 0x00ff) << 8) | (((device->val[2]) & 0xff00) >> 8)) << 32) |
    ((UINT64)
    (UINT16)((((device->val[3]) & 0x00ff) << 8) | (((device->val[3]) & 0xff00) >> 8)) << 48));

    return (0);
}
```

**Error**
```
Output of power64le clang (trunk) (Compiler #1)
fatal error: error in backend: Cannot select: 0x563593150ae0: ch = PPCISD::STBRX<(store (s64) into %ir.0, !tbaa !49)> 0x5635930f91d8, 0x563593151570, 0x563593150738, ValueType:ch:i64, example.cpp:11:17
  0x563593151570: i64,ch = load<(load (s64) from %ir.2)> 0x5635930f91d8, 0x563593150808, undef:i64, example.cpp:16:94
    0x563593150808: i64 = add nuw 0x563593150738, Constant:i64<8>, example.cpp:12:25
      0x563593150738: i64,ch = CopyFromReg 0x5635930f91d8, Register:i64 %0
        0x5635931506d0: i64 = Register %0
      0x5635931507a0: i64 = Constant<8>
    0x5635931508d8: i64 = undef
  0x563593150738: i64,ch = CopyFromReg 0x5635930f91d8, Register:i64 %0
    0x5635931506d0: i64 = Register %0
In function: _Z6myFuncP8Mystruct
```

**Stack dump**
```
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -S -target powerpc64le -fcolor-diagnostics -fno-crash-diagnostics -mcpu=a2 --target=ppc64 -O2 <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@_Z6myFuncP8Mystruct'
 #0 0x000056358c5e060f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000056358c5de444 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35de444)
 #2 0x000056358c5179d2 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35179d2)
 #3 0x000056358c5d6f9e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35d6f9e)
 #4 0x000056358a1c33f6 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11c33f6)
 #5 0x000056358c51f1ff llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x351f1ff)
 #6 0x000056358d4b7cf6 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44b7cf6)
 #7 0x000056358d4baca2 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44baca2)
 #8 0x000056358ae6c9e7 (anonymous namespace)::PPCDAGToDAGISel::Select(llvm::SDNode*) PPCISelDAGToDAG.cpp:0:0
 #9 0x000056358d4b6854 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44b6854)
#10 0x000056358d4be1c6 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44be1c6)
#11 0x000056358d4c184b llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44c184b)
#12 0x000056358d4c3a3f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.889) SelectionDAGISel.cpp:0:0
#13 0x000056358ae72f46 (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) PPCISelDAGToDAG.cpp:0:0
#14 0x000056358b91b2e8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x291b2e8)
#15 0x000056358bd8c2a9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d8c2a9)
#16 0x000056358bd8c541 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d8c541)
#17 0x000056358bd8cfe7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d8cfe7)
#18 0x000056358c92fce2 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x392fce2)
#19 0x000056358d5d961f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45d961f)
#20 0x000056358e50bc59 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x550bc59)
#21 0x000056358d5da0bd clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45da0bd)
#22 0x000056358cfbd851 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fbd851)
#23 0x000056358cf55552 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f55552)
#24 0x000056358d08a073 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x408a073)
#25 0x000056358a1c4f34 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11c4f34)
#26 0x000056358a1c0edd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x000056358cde8b05 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x000056358c517863 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3517863)
#29 0x000056358cdeabd8 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3deabd8)
#30 0x000056358cdbb1ea clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dbb1ea)
#31 0x000056358cdbbd2f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dbbd2f)
#32 0x000056358cdc4785 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3dc4785)
#33 0x000056358a0efc4f main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x10efc4f)
#34 0x00007f19b123d0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#35 0x000056358a1c0a5a _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11c0a5a)
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```

**Notes**

A2 is the only CPU this manifests itself on. Appears to be introduced in LLVM 14, as this is not reproducible on LLVM 13.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWltzozoS_jXOi8ou7uCHPDh2fE625uJKMlO7--ISSNjsYGBBJPa_324JbITtSeaEc87DTjEO6NL9davVF0GYs8PtyJrBNc93RZJykhciybNqZM9U-8hYjIzmN0pptiHjsaDlhouRvSiKyHPIeBcVNTxRi4y_WoTv6a5I-SQqiu5kRa7b2aXvGc0lH8Wh4IzHJM2BX51VySbjjCSZIN8evjx7zsi-0wcex1TbvFSjTO84Sh9bibKOBBn5TS-Bf8f5kmNW745ztV5F_YWmI_fOGbmLEwd_QT4fFOUeW0S9OyzrLCIjK2gHwf2M8Zck4iNr2tLosFR945F9D2AIKBcnK-EJzrACbDi2HYng3KYVFCAHHq8TTSWBgRJYUxjvEWNvGHEsn-w5XCSQ9_6cvHN6HBuGmn4Pl5yuLiSiYfsYaPNjoM13gG6pSSwDw7c-Bt_6Bfi2NTx8-2Pw7V-A77QmpG8nRFtyUZcZsjG0Af7iojfp-p_7sszLn3ier7UoakHymBT5Ky89B1yicnvADXZu9kPhDxp_WcK9bR51GVNBU8IlE3umbsBvkZBGP3jGsG1OsywXpOIpR18xA0W4nu1ObdM1KDewJdrKHb9azR-eFuiJ7dnT893jP1EzVlCJvOQIoZKLiG4xh0c3KSegDtS-KUJK8a-jFHh_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