<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62171>62171</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
A/F: `(OpVT.getVectorElementType() == MVT::f32 || OpVT.getVectorElementType() == MVT:f64) && "Illegal vector type for X86ISD::TESTP"' after 3a0c1d5
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dyung
</td>
</tr>
</table>
<pre>
One of our internal tests started hitting an assertion failure which I bisected back to commit 3a0c1d5. Consider the following reduced testcase:
```c++
#include <x86intrin.h>
typedef int a;
typedef float __attribute__((__vector_size__(32))) b;
__attribute__((__vector_size__(8 * sizeof(a)))) a c;
b *d;
b e;
int f;
__attribute__((__vector_size__(2 * sizeof(long)))) long g;
void h() {
for (;;) {
c = __builtin_ia32_cmpps256(d[0], e, 0);
__attribute__((__vector_size__(
4 * sizeof(int)))) int i = __builtin_ia32_vextractf128_si256(c, 0),
j = __builtin_ia32_vextractf128_si256(c, 1);
g = i | j;
f = __builtin_ia32_pmovmskb128(g);
if (f)
break;
}
}
```
If compiled with `-mavx -O2`, the compiler hits an assertion failure if the compiler contains the change in 3a0c1d5:
```
clang++: /root/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:43780: virtual bool llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(llvm::SDValue, const llvm::APInt&, const llvm::APInt&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int) const: Assertion `(OpVT.getVectorElementType() == MVT::f32 || OpVT.getVectorElementType() == MVT::f64) && "Illegal vector type for X86ISD::TESTP"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -mavx -O2 <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 '@_Z1hv'
#0 0x000056147f66b1cf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c6b1cf)
#1 0x000056147f668f0c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c68f0c)
#2 0x000056147f5b6078 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fe56291f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fe5623ec00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fe5623cb859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fe5623cb729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fe5623dcfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000056147e2a2078 llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(llvm::SDValue, llvm::APInt const&, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x28a2078)
#9 0x00005614807840db llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d840db)
#10 0x0000561480795bbd llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&, unsigned int, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d95bbd)
#11 0x0000561480795d9d llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d95d9d)
#12 0x000056147e3937a9 llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x29937a9)
#13 0x00005614806031c4 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#14 0x0000561480604b30 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c04b30)
#15 0x000056148072c644 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d2c644)
#16 0x000056148072fe28 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d2fe28)
#17 0x0000561480731e81 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#18 0x000056147e21a570 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#19 0x000056147ea240de llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#20 0x000056147efd6551 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35d6551)
#21 0x000056147efd6799 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35d6799)
#22 0x000056147efd7012 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35d7012)
#23 0x000056147f8ded6e 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>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eded6e)
#24 0x0000561480894b3c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e94b3c)
#25 0x0000561481d65cf9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6365cf9)
#26 0x00005614808933b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e933b8)
#27 0x00005614800f50d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46f50d9)
#28 0x00005614800795f6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46795f6)
#29 0x00005614801d9367 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47d9367)
#30 0x000056147cbe0196 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11e0196)
#31 0x000056147cbdbfba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#32 0x000056147fee04ad 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
#33 0x000056147f5b6560 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb6560)
#34 0x000056147fee0d6f 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
#35 0x000056147fea87ac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44a87ac)
#36 0x000056147fea924d 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+++0x44a924d)
#37 0x000056147feb111d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b111d)
#38 0x000056147cbde640 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11de640)
#39 0x000056147cae95f5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10e95f5)
#40 0x00007fe5623cd083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#41 0x000056147cbd6cce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x11d6cce)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
Link to failure: https://godbolt.org/z/fjzqosYa6
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z4yiX_jXKDeWUhD59kQvHTvrNbM92qp2dmt0bF4Ijm2kJ9AJykvn1WyDZForTnd5Nuvat7fJkbECH5zycLxBEa74VAFdBeh2kqwvSmZ1UV-y5E9uLUrLnqy8CkKyQ7BTiwoASpEYG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