Skip to content

Commit 73a3d35

Browse files
committed
[SVE][CodeGen] Fix up warnings in sve-split-insert/extract tests
I have fixed up some more ElementCount/TypeSize related warnings in the following tests: CodeGen/AArch64/sve-split-extract-elt.ll CodeGen/AArch64/sve-split-insert-elt.ll In SelectionDAG::CreateStackTemporary we were relying upon the implicit cast from TypeSize -> uint64_t when calling MachineFrameInfo::CreateStackObject. I've fixed this by passing in the known minimum size instead, which I believe is fine because the associated stack id indicates whether this is a scalable object or not. I've also fixed up a case in TargetLowering::SimplifyDemandedBits when extracting a vector element from a scalable vector. The result is a scalar, hence it wasn't caught at the start of the function. If the vector is scalable we just bail out for now. Differential Revision: https://reviews.llvm.org/D86431
1 parent ab86e64 commit 73a3d35

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

llvm/include/llvm/Support/TypeSize.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ class ElementCount {
116116

117117
unsigned getKnownMinValue() const { return Min; }
118118

119+
// Return the minimum value with the assumption that the count is exact.
120+
// Use in places where a scalable count doesn't make sense (e.g. non-vector
121+
// types, or vectors in backends which don't support scalable vectors).
122+
unsigned getFixedValue() const {
123+
assert(!Scalable &&
124+
"Request for a fixed element count on a scalable object");
125+
return Min;
126+
}
127+
119128
bool isScalable() const { return Scalable; }
120129
};
121130

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,9 @@ SDValue SelectionDAG::CreateStackTemporary(TypeSize Bytes, Align Alignment) {
20302030
int StackID = 0;
20312031
if (Bytes.isScalable())
20322032
StackID = TFI->getStackIDForScalableVectors();
2033-
int FrameIdx = MFI.CreateStackObject(Bytes, Alignment,
2033+
// The stack id gives an indication of whether the object is scalable or
2034+
// not, so it's safe to pass in the minimum size here.
2035+
int FrameIdx = MFI.CreateStackObject(Bytes.getKnownMinSize(), Alignment,
20342036
false, nullptr, StackID);
20352037
return getFrameIndex(FrameIdx, TLI->getFrameIndexTy(getDataLayout()));
20362038
}

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,10 +2022,14 @@ bool TargetLowering::SimplifyDemandedBits(
20222022
case ISD::EXTRACT_VECTOR_ELT: {
20232023
SDValue Src = Op.getOperand(0);
20242024
SDValue Idx = Op.getOperand(1);
2025-
unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
2025+
ElementCount SrcEltCnt = Src.getValueType().getVectorElementCount();
20262026
unsigned EltBitWidth = Src.getScalarValueSizeInBits();
20272027

2028+
if (SrcEltCnt.isScalable())
2029+
return false;
2030+
20282031
// Demand the bits from every vector element without a constant index.
2032+
unsigned NumSrcElts = SrcEltCnt.getFixedValue();
20292033
APInt DemandedSrcElts = APInt::getAllOnesValue(NumSrcElts);
20302034
if (auto *CIdx = dyn_cast<ConstantSDNode>(Idx))
20312035
if (CIdx->getAPIntValue().ult(NumSrcElts))

llvm/test/CodeGen/AArch64/sve-split-extract-elt.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
2+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
3+
; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
4+
5+
; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
6+
; WARN-NOT: warning
37

48
; EXTRACT VECTOR ELT
59

llvm/test/CodeGen/AArch64/sve-split-insert-elt.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
2+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
3+
; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
4+
5+
; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
6+
; WARN-NOT: warning
37

48
; INSERT VECTOR ELT
59

0 commit comments

Comments
 (0)