Skip to content

Commit 3f55cc6

Browse files
committed
[AArch64] Disconnect FeatureUseScalarIncVL from FeatureSVE2.
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 attempt to break that, enabling the feature if SVE2 or SME is present and the use-scalar-inc-vl is not otherwise specified, but not requiring a hard dependency between the two. (Unfortunately I had to check if the value was present in the features string to check that). It also inverts the meaning of the feature to DontUseScalarIncVL, so that the default state is to use addvl, hopefully the more sensible default going forward.
1 parent 95fb7f8 commit 3f55cc6

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 5 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]>;
@@ -797,6 +794,9 @@ def FeatureUseFixedOverScalableIfEqualCost: SubtargetFeature<"use-fixed-over-sca
797794
"UseFixedOverScalableIfEqualCost", "true",
798795
"Prefer fixed width loop vectorization over scalable if the cost-model assigns equal costs">;
799796

797+
def FeatureDontUseScalarIncVL : SubtargetFeature<"dont-use-scalar-inc-vl",
798+
"DontUseScalarIncVL", "true", "Prefer add+cnt over inc/dec">;
799+
800800
//===----------------------------------------------------------------------===//
801801
// Architectures.
802802
//

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ def UseNegativeImmediates
375375
: Predicate<"false">, AssemblerPredicate<(all_of (not FeatureNoNegativeImmediates)),
376376
"NegativeImmediates">;
377377

378-
def UseScalarIncVL : Predicate<"Subtarget->useScalarIncVL()">;
378+
def UseScalarIncVL : Predicate<"!Subtarget->dontUseScalarIncVL()">;
379379

380-
def NoUseScalarIncVL : Predicate<"!Subtarget->useScalarIncVL()">;
380+
def NoUseScalarIncVL : Predicate<"Subtarget->dontUseScalarIncVL()">;
381381

382382
def UseSVEFPLD1R : Predicate<"!Subtarget->noSVEFPLD1R()">;
383383

llvm/lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ void AArch64Subtarget::initializeProperties(bool HasMinSize) {
335335

336336
if (AArch64MinimumJumpTableEntries.getNumOccurrences() > 0 || !HasMinSize)
337337
MinimumJumpTableEntries = AArch64MinimumJumpTableEntries;
338+
339+
// If only SVE is present (not SVE2 or SME) and DontUseScalarIncVL is not
340+
// otherwise set, enable it by default.
341+
if (!hasSVE2() && !hasSME()) {
342+
if (!getFeatureString().contains("dont-use-scalar-inc-vl"))
343+
DontUseScalarIncVL = true;
344+
}
338345
}
339346

340347
AArch64Subtarget::AArch64Subtarget(const Triple &TT, StringRef CPU,

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 -mattr=-dont-use-scalar-inc-vl < %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 -mattr=-dont-use-scalar-inc-vl < %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 -mattr=+dont-use-scalar-inc-vl < %s | FileCheck %s
7+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme -mattr=+dont-use-scalar-inc-vl -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 -mattr=-dont-use-scalar-inc-vl -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 -mattr=+dont-use-scalar-inc-vl -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)