Skip to content

Commit

Permalink
[AArch64][GlobalISel] Fix legalization for <4 x i1> vector stores.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aemerson authored Jan 6, 2025
1 parent 6b0807f commit 2d53eaf
Show file tree
Hide file tree
Showing 3 changed files with 435 additions and 158 deletions.
5 changes: 1 addition & 4 deletions llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4118,10 +4118,7 @@ LegalizerHelper::LegalizeResult LegalizerHelper::lowerStore(GStore &StoreMI) {
unsigned StoreWidth = MemTy.getSizeInBits();
unsigned StoreSizeInBits = 8 * MemTy.getSizeInBytes();

if (StoreWidth != StoreSizeInBits) {
if (SrcTy.isVector())
return UnableToLegalize;

if (StoreWidth != StoreSizeInBits && !SrcTy.isVector()) {
// Promote to a byte-sized store with upper bits zero if not
// storing an integral number of bytes. For example, promote
// TRUNCSTORE:i1 X -> TRUNCSTORE:i8 (and X, 1)
Expand Down
6 changes: 5 additions & 1 deletion llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
.clampMaxNumElements(0, p0, 2)
.lowerIfMemSizeNotPow2()
// TODO: Use BITCAST for v2i8, v2i16 after G_TRUNC gets sorted out
.bitcastIf(typeInSet(0, {v4s8}),
.bitcastIf(all(typeInSet(0, {v4s8}),
LegalityPredicate([=](const LegalityQuery &Query) {
return Query.Types[0].getSizeInBits() ==
Query.MMODescrs[0].MemoryTy.getSizeInBits();
})),
[=](const LegalityQuery &Query) {
const LLT VecTy = Query.Types[0];
return std::pair(0, LLT::scalar(VecTy.getSizeInBits()));
Expand Down
Loading

0 comments on commit 2d53eaf

Please sign in to comment.