Skip to content

Commit 1d6d073

Browse files
committed
[AArch64] Remove FeatureUseScalarIncVL
FeatureUseScalarIncVL is a tuning feature, used to control whether addvl or add+cnt is used. It was previously added as a dependency for FeatureSVE2, an architecture feature but this can be seen as a layering violation. The main disadvantage is that -use-scalar-inc-vl cannot be used without disabling sve2 and all dependant features. This patch now replaces that with an option that if unset defaults to hasSVE || hasSME, but is otherwise overriden by the option. The hope is that no cpus will rely on the tuning feature (or we can readdit if needed.
1 parent 99f1019 commit 1d6d073

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,9 @@ def FeatureTHE : ExtensionWithMArch<"the", "THE", "FEAT_THE",
358358
// Armv9.0 Architecture Extensions
359359
//===----------------------------------------------------------------------===//
360360

361-
def FeatureUseScalarIncVL : SubtargetFeature<"use-scalar-inc-vl",
362-
"UseScalarIncVL", "true", "Prefer inc/dec over add+cnt">;
363-
364361
def FeatureSVE2 : ExtensionWithMArch<"sve2", "SVE2", "FEAT_SVE2",
365362
"Enable Scalable Vector Extension 2 (SVE2) instructions",
366-
[FeatureSVE, FeatureUseScalarIncVL]>;
363+
[FeatureSVE]>;
367364

368365
def FeatureSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES",
369366
"FEAT_SVE_AES, FEAT_SVE_PMULL128",
@@ -403,7 +400,7 @@ def FeatureRME : Extension<"rme", "RME", "FEAT_RME",
403400
"Enable Realm Management Extension">;
404401

405402
def FeatureSME : ExtensionWithMArch<"sme", "SME", "FEAT_SME",
406-
"Enable Scalable Matrix Extension (SME)", [FeatureBF16, FeatureUseScalarIncVL]>;
403+
"Enable Scalable Matrix Extension (SME)", [FeatureBF16]>;
407404

408405
def FeatureSMEF64F64 : ExtensionWithMArch<"sme-f64f64", "SMEF64F64", "FEAT_SME_F64F64",
409406
"Enable Scalable Matrix Extension (SME) F64F64 instructions", [FeatureSME]>;

llvm/lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ static cl::opt<bool>
9393
cl::init(false), cl::Hidden,
9494
cl::desc("Enable subreg liveness tracking"));
9595

96+
static cl::opt<bool>
97+
UseScalarIncVL("sve-use-scalar-inc-vl", cl::init(false), cl::Hidden,
98+
cl::desc("Prefer add+cnt over addvl/inc/dec"));
99+
96100
unsigned AArch64Subtarget::getVectorInsertExtractBaseCost() const {
97101
if (OverrideVectorInsertExtractBaseCost.getNumOccurrences() > 0)
98102
return OverrideVectorInsertExtractBaseCost;
@@ -575,6 +579,14 @@ void AArch64Subtarget::mirFileLoaded(MachineFunction &MF) const {
575579

576580
bool AArch64Subtarget::useAA() const { return UseAA; }
577581

582+
bool AArch64Subtarget::useScalarIncVL() const {
583+
// If SVE2 or SME is present (we are not SVE-1 only) and UseScalarIncVL
584+
// is not otherwise set, enable it by default.
585+
if (UseScalarIncVL.getNumOccurrences())
586+
return UseScalarIncVL;
587+
return hasSVE2() || hasSME();
588+
}
589+
578590
// If return address signing is enabled, tail calls are emitted as follows:
579591
//
580592
// ```

llvm/lib/Target/AArch64/AArch64Subtarget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
417417
return DefaultSVETFOpts;
418418
}
419419

420+
/// Returns true to use the addvl/inc/dec instructions, as opposed to separate
421+
/// add + cnt instructions.
422+
bool useScalarIncVL() const;
423+
420424
const char* getChkStkName() const {
421425
if (isWindowsArm64EC())
422426
return "#__chkstk_arm64ec";

llvm/test/CodeGen/AArch64/sve-intrinsics-counting-elems-i32.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s -check-prefix=NO_SCALAR_INC
3-
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -mattr=+use-scalar-inc-vl < %s | FileCheck %s
3+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -sve-use-scalar-inc-vl=true < %s | FileCheck %s
44
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
55

66
; INCB

llvm/test/CodeGen/AArch64/sve-intrinsics-counting-elems.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
3-
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -mattr=+use-scalar-inc-vl < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
3+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -sve-use-scalar-inc-vl=true < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
44
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
55
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme -force-streaming < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
6+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -sve-use-scalar-inc-vl=false < %s | FileCheck %s
7+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme -sve-use-scalar-inc-vl=false -force-streaming < %s | FileCheck %s
68

79
;
810
; CNTB

llvm/test/CodeGen/AArch64/sve-vl-arith.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
22
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -verify-machineinstrs < %s | FileCheck %s -check-prefix=NO_SCALAR_INC
3-
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -mattr=+use-scalar-inc-vl -verify-machineinstrs < %s | FileCheck %s
3+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -sve-use-scalar-inc-vl=true -verify-machineinstrs < %s | FileCheck %s
44
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -verify-machineinstrs < %s | FileCheck %s
5+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -sve-use-scalar-inc-vl=false -verify-machineinstrs < %s | FileCheck %s -check-prefix=NO_SCALAR_INC
56

67
define <vscale x 8 x i16> @inch_vec(<vscale x 8 x i16> %a) {
78
; NO_SCALAR_INC-LABEL: inch_vec:

0 commit comments

Comments
 (0)