Skip to content

Commit 9329a30

Browse files
committed
Add getSVEVectorSizeInBits to query known SVE length
1 parent 2becfc6 commit 9329a30

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7385,14 +7385,13 @@ bool AArch64DAGToDAGISel::SelectAddrModeIndexedSVE(SDNode *Root, SDValue N,
73857385
MulImm = cast<ConstantSDNode>(VScale.getOperand(0))->getSExtValue();
73867386
} else if (auto C = dyn_cast<ConstantSDNode>(VScale)) {
73877387
int64_t ByteOffset = C->getSExtValue();
7388-
constexpr auto SVEBitsPerBlock = AArch64::SVEBitsPerBlock;
7389-
auto MinVScale = Subtarget->getMinSVEVectorSizeInBits() / SVEBitsPerBlock;
7390-
auto MaxVScale = Subtarget->getMaxSVEVectorSizeInBits() / SVEBitsPerBlock;
7388+
const auto KnownVScale =
7389+
Subtarget->getSVEVectorSizeInBits() / AArch64::SVEBitsPerBlock;
73917390

7392-
if (!MaxVScale || MinVScale != MaxVScale || ByteOffset % MaxVScale != 0)
7391+
if (!KnownVScale || ByteOffset % KnownVScale != 0)
73937392
return false;
73947393

7395-
MulImm = ByteOffset / MaxVScale;
7394+
MulImm = ByteOffset / KnownVScale;
73967395
} else
73977396
return false;
73987397

llvm/lib/Target/AArch64/AArch64Subtarget.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
391391
void mirFileLoaded(MachineFunction &MF) const override;
392392

393393
// Return the known range for the bit length of SVE data registers. A value
394-
// of 0 means nothing is known about that particular limit beyong what's
394+
// of 0 means nothing is known about that particular limit beyond what's
395395
// implied by the architecture.
396396
unsigned getMaxSVEVectorSizeInBits() const {
397397
assert(isSVEorStreamingSVEAvailable() &&
@@ -405,6 +405,17 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
405405
return MinSVEVectorSizeInBits;
406406
}
407407

408+
// Return the known bit length of SVE data registers. A value of 0 means the
409+
// length is unkown beyond what's implied by the architecture.
410+
unsigned getSVEVectorSizeInBits() const {
411+
assert(isSVEorStreamingSVEAvailable() &&
412+
"Tried to get SVE vector length without SVE support!");
413+
if (MaxSVEVectorSizeInBits &&
414+
MinSVEVectorSizeInBits == MaxSVEVectorSizeInBits)
415+
return MaxSVEVectorSizeInBits;
416+
return 0;
417+
}
418+
408419
bool useSVEForFixedLengthVectors() const {
409420
if (!isSVEorStreamingSVEAvailable())
410421
return false;

0 commit comments

Comments
 (0)