forked from OSchip/llvm-project
[AArch64][GlobalISel] Fix a crash during unsuccessful G_CTPOP <2 x s64> legalization.
The legalization rule for scalar-same-as doesn't handle vectors. Until we implement custom legalization for this, at least fall back properly.
This commit is contained in:
parent
8fdfead71a
commit
af6eb1c710
|
@ -956,6 +956,23 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
/// Conditionally narrow the scalar or elt to match the size of another.
|
||||
LegalizeRuleSet &maxScalarEltSameAsIf(LegalityPredicate Predicate,
|
||||
unsigned TypeIdx,
|
||||
unsigned SmallTypeIdx) {
|
||||
typeIdx(TypeIdx);
|
||||
return narrowScalarIf(
|
||||
[=](const LegalityQuery &Query) {
|
||||
return Query.Types[SmallTypeIdx].getScalarSizeInBits() <
|
||||
Query.Types[TypeIdx].getScalarSizeInBits() &&
|
||||
Predicate(Query);
|
||||
},
|
||||
[=](const LegalityQuery &Query) {
|
||||
LLT T = Query.Types[SmallTypeIdx];
|
||||
return std::make_pair(TypeIdx, T);
|
||||
});
|
||||
}
|
||||
|
||||
/// Add more elements to the vector to reach the next power of two.
|
||||
/// No effect if the type is not a vector or the element count is a power of
|
||||
/// two.
|
||||
|
|
|
@ -726,11 +726,13 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
|
|||
// TODO: Custom legalization for s128
|
||||
// TODO: v2s64, v2s32, v4s32, v4s16, v8s16
|
||||
// TODO: Use generic lowering when custom lowering is not possible.
|
||||
auto always = [=](const LegalityQuery &Q) { return true; };
|
||||
getActionDefinitionsBuilder(G_CTPOP)
|
||||
.legalFor({{v8s8, v8s8}, {v16s8, v16s8}})
|
||||
.clampScalar(0, s32, s128)
|
||||
.widenScalarToNextPow2(0)
|
||||
.scalarSameSizeAs(1, 0)
|
||||
.minScalarEltSameAsIf(always, 1, 0)
|
||||
.maxScalarEltSameAsIf(always, 1, 0)
|
||||
.customFor({{s32, s32}, {s64, s64}});
|
||||
|
||||
computeTables();
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
|
||||
# RUN: llc -mtriple=aarch64-unknown-unknown -verify-machineinstrs -run-pass=legalizer %s -o - -global-isel-abort=2 | FileCheck %s
|
||||
...
|
||||
# This test doesn't currently legalize but should at least not crash.
|
||||
---
|
||||
name: v2s64_dont_crash
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: $q0
|
||||
; CHECK-LABEL: name: v2s64_dont_crash
|
||||
; CHECK: liveins: $q0
|
||||
; CHECK: %copy:_(<2 x s64>) = COPY $q0
|
||||
; CHECK: %ctpop:_(<2 x s64>) = G_CTPOP %copy(<2 x s64>)
|
||||
; CHECK: $q0 = COPY %ctpop(<2 x s64>)
|
||||
; CHECK: RET_ReallyLR implicit $q0
|
||||
%copy:_(<2 x s64>) = COPY $q0
|
||||
%ctpop:_(<2 x s64>) = G_CTPOP %copy(<2 x s64>)
|
||||
$q0 = COPY %ctpop(<2 x s64>)
|
||||
RET_ReallyLR implicit $q0
|
||||
|
||||
...
|
Loading…
Reference in New Issue