Skip to content

Commit 2d53eaf

Browse files
authored
[AArch64][GlobalISel] Fix legalization for <4 x i1> vector stores.
This case is different from the earlier <8 x i1> case handled because it triggers a legalization failure in lowerStore() that's intended for scalar code. It also was triggering incorrect bitcast actions in the AArch64 rules that weren't expecting truncating stores. With these two fixed, more cases are handled. The code is still bad, including some missing load promotion in our combiners that result in dead stores hanging around at the end of codegen. Again, we can fix these in separate changes. Reviewers: davemgreen, madhur13490, topperc, arsenm Reviewed By: davemgreen Pull Request: llvm#121185
1 parent 6b0807f commit 2d53eaf

File tree

3 files changed

+435
-158
lines changed

3 files changed

+435
-158
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,10 +4118,7 @@ LegalizerHelper::LegalizeResult LegalizerHelper::lowerStore(GStore &StoreMI) {
41184118
unsigned StoreWidth = MemTy.getSizeInBits();
41194119
unsigned StoreSizeInBits = 8 * MemTy.getSizeInBytes();
41204120

4121-
if (StoreWidth != StoreSizeInBits) {
4122-
if (SrcTy.isVector())
4123-
return UnableToLegalize;
4124-
4121+
if (StoreWidth != StoreSizeInBits && !SrcTy.isVector()) {
41254122
// Promote to a byte-sized store with upper bits zero if not
41264123
// storing an integral number of bytes. For example, promote
41274124
// TRUNCSTORE:i1 X -> TRUNCSTORE:i8 (and X, 1)

llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
467467
.clampMaxNumElements(0, p0, 2)
468468
.lowerIfMemSizeNotPow2()
469469
// TODO: Use BITCAST for v2i8, v2i16 after G_TRUNC gets sorted out
470-
.bitcastIf(typeInSet(0, {v4s8}),
470+
.bitcastIf(all(typeInSet(0, {v4s8}),
471+
LegalityPredicate([=](const LegalityQuery &Query) {
472+
return Query.Types[0].getSizeInBits() ==
473+
Query.MMODescrs[0].MemoryTy.getSizeInBits();
474+
})),
471475
[=](const LegalityQuery &Query) {
472476
const LLT VecTy = Query.Types[0];
473477
return std::pair(0, LLT::scalar(VecTy.getSizeInBits()));

0 commit comments

Comments
 (0)