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

    <tr>
        <th>Summary</th>
        <td>
            Clang-20 : Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
        </td>
    </tr>

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

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

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

<pre>
    ### Description
I encountered a crash in Clang-20 when compiling the following code snippet:

```c
int a, b;
int __attribute__((__target__("avx512bw,no-evex512"))) c() {
 return __builtin_ia32_kunpcksi(a, b);
}
```

### Command

The compilation command used was:
```sh
clang -fno-rtlib-add-rpath  -fno-ident -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address   test.c
```

### Error Message
```sh
clang: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:969: void {anonymous}::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fno-rtlib-add-rpath -fno-ident -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@c'
 #0 0x0000000003bf0cf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bf0cf8)
 #1 0x0000000003bee9fc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bee9fc)
 #2 0x0000000003b3c0e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000077139de42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000077139de969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000077139de42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000077139de287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000077139de2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000077139de39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000004e06bc3 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (.part.0) LegalizeDAG.cpp:0:0
#10 0x0000000004e092a3 llvm::SelectionDAG::Legalize() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e092a3)
#11 0x0000000004efcfdd llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4efcfdd)
#12 0x0000000004f00732 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f00732)
#13 0x0000000004f01a50 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f01a50)
#14 0x0000000004ef231f llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ef231f)
#15 0x0000000002f472f9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x000000000354dbb0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x354dbb0)
#17 0x000000000354df61 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x354df61)
#18 0x000000000354e817 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x354e817)
#19 0x0000000003ea647b clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ea647b)
#20 0x00000000045732ce clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45732ce)
#21 0x000000000650c3cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x650c3cc)
#22 0x00000000045736a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x45736a8)
#23 0x000000000482df89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x482df89)
#24 0x00000000047ade9e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47ade9e)
#25 0x0000000004918d3e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4918d3e)
#26 0x0000000000ca83a7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca83a7)
#27 0x0000000000c9ff6a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x00000000045b68a9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#29 0x0000000003b3c594 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b3c594)
#30 0x00000000045b6e9f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#31 0x000000000457d18d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457d18d)
#32 0x000000000457e27d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x457e27d)
#33 0x0000000004585635 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4585635)
#34 0x0000000000ca5213 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xca5213)
#35 0x0000000000b7be24 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xb7be24)
#36 0x000077139de29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x000077139de29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000c9fa1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc9fa1e)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/qvGPsG9hK
Please let me know if you need any more details.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl9z4ygS_zTKCyWXhGz9eciDxo5nszdzSU2yu_fmQqhlc8GgBZQ4--mvQLItnGQyufNuXdXdlCe2-NP8uvl10yCI1mwtAC6D2adgtrggndlIdcnIlggpnrey01RfVLJ-vgxw0n_QAjRVrDVMiiBaBFF5jUBQ2QkDCmpEEFVEbxATaM6JWIc4Qk8bEIjKbcs4E2tkNoAaybl8sk9U1oC0YG0LJkjKXubwN436D-2fmTCIBHiOqiD5dCxarYgxilWdgdUqwHmA89XKELUGMzxj8ribxbh6CvBcyBAewT4GGAe46D-IuoYFCrJBMlJgOiXQalV1jBsmVowkePXQiZY-aBbgfICCiwOaIFucIPfUOdhwLrdbIupx5f0GBhMRa1r72zZBnYYaPRF9NM1etN70BdSaGYWNkKEynFUhqetQtcRsUF_KahAGhTcJCpuGaBNubV34G-Echb_BzijSN9RGMWpCwhnRzMl8UqR9RKH9qYlghv0BQbIgda1Aa4SQAW0m9Id0vlJKKvQVtCZr-J4qQVKiAC-VlCbAS84ft2Gr5D-B7h_tF6sCvJzLGj6DCPDyDjhQa7dF-TnAyy-wJpz9AYvy84S2bZCURVpYuY-S1XaKD_y2M5aUQVKOJey79zX7p5s2wLkbv--w-LusIcClI0CJSq1BuamzOuH8_sv1ZA3m_rmF0gl2BCstpDWYuRQGdqYnneXRTWuLfyW8A9tlX1GgIFkEyQLdOz5_kU-gmLNRkJS2oUOHgmweZHshNy11yPJR9-u7Qc9ezlwKbYgwH-j4DdZMG1CuDqcBTlGA8S8Cdi1QA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