[llvm] [SelectionDAG] Add support for the 3-way comparison intrinsics [US]CMP (PR #91871)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 08:00:26 PDT 2024
nikic wrote:
```llvm
define <2 x i16> @test_ucmp.2.8.16(<2 x i8> %x, <2 x i8> %y) {
%1 = call <2 x i16> @llvm.ucmp(<2 x i8> %x, <2 x i8> %y)
ret <2 x i16> %1
}
```
Asserts:
```
llc: /home/npopov/repos/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7434: SDValue llvm::SelectionDAG::getNode(unsigned int, const SDLoc &, EVT, SDValue, SDValue, SDValue, const SDNodeFlags): Assertion `(VT.isScalableVector() != N2VT.isScalableVector() || VT.getVectorMinNumElements() >= N2VT.getVectorMinNumElements()) && "Insert subvector must be from smaller vector to larger vector!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: build/bin/llc test.ll
1. Running pass 'Function Pass Manager' on module 'test.ll'.
2. Running pass 'X86 DAG->DAG Instruction Selection' on function '@test_ucmp.2.8.16'
#0 0x0000000006474828 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build/bin/llc+0x6474828)
#1 0x00000000064723ee llvm::sys::RunSignalHandlers() (build/bin/llc+0x64723ee)
#2 0x0000000006474ed8 SignalHandler(int) Signals.cpp:0:0
#3 0x00007f2303c53710 __restore_rt (/lib64/libc.so.6+0x40710)
#4 0x00007f2303cab144 __pthread_kill_implementation (/lib64/libc.so.6+0x98144)
#5 0x00007f2303c5365e gsignal (/lib64/libc.so.6+0x4065e)
#6 0x00007f2303c3b902 abort (/lib64/libc.so.6+0x28902)
#7 0x00007f2303c3b81e _nl_load_domain.cold (/lib64/libc.so.6+0x2881e)
#8 0x00007f2303c4b977 (/lib64/libc.so.6+0x38977)
#9 0x0000000006249fd7 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::SDNodeFlags) (build/bin/llc+0x6249fd7)
#10 0x00000000062f4a41 llvm::DAGTypeLegalizer::WidenVecRes_CMP(llvm::SDNode*) LegalizeVectorTypes.cpp:0:0
#11 0x00000000062ed2bd llvm::DAGTypeLegalizer::WidenVectorResult(llvm::SDNode*, unsigned int) LegalizeVectorTypes.cpp:0:0
#12 0x0000000006294fdb llvm::DAGTypeLegalizer::run() LegalizeTypes.cpp:0:0
```
I'm using this script to generate test cases:
```php
<?php
function makeType(int $numElems, int $bw): string {
$ty = 'i' . $bw;
if ($numElems != 0) {
return '<' . $numElems . ' x ' . $ty . '>';
}
return $ty;
}
$bws = [1, 2, 3, 4, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, 127, 128, 129, 255, 256, 257];
foreach (['ucmp', 'scmp'] as $intrin) {
for ($numElems = 0; $numElems < 100; ++$numElems) {
foreach ($bws as $argBW) {
foreach ($bws as $resBW) {
if ($resBW == 1) {
continue;
}
$argType = makeType($numElems, $argBW);
$resType = makeType($numElems, $resBW);
echo "define $resType @test_$intrin.$numElems.$argBW.$resBW($argType %x, $argType %y) {\n";
echo " %1 = call $resType @llvm.$intrin($argType %x, $argType %y)\n";
echo " ret $resType %1\n";
echo "}\n";
echo "\n";
}
}
}
}
```
https://github.com/llvm/llvm-project/pull/91871
More information about the llvm-commits
mailing list