Skip to content

Commit bd6e904

Browse files
[LLVM][AArch64] Relax SVE codegen predicates for sm4 instructions (#147524)
Adds sve-sm4 to reference FEAT_SVE_SM4 without specifically enabling SVE2.
1 parent b9d7513 commit bd6e904

21 files changed

+48
-26
lines changed

clang/test/CodeGen/AArch64/fmv-dependencies.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,6 @@ int caller() {
189189
// CHECK: attributes #[[sve2_aes]] = { {{.*}} "target-features"="+aes,+fp-armv8,+fullfp16,+neon,+outline-atomics,+sve,+sve-aes,+sve2,+sve2-aes,+v8a"
190190
// CHECK: attributes #[[sve2_bitperm]] = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+outline-atomics,+sve,+sve-bitperm,+sve2,+sve2-bitperm,+v8a"
191191
// CHECK: attributes #[[sve2_sha3]] = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+outline-atomics,+sha2,+sha3,+sve,+sve-sha3,+sve2,+sve2-sha3,+v8a"
192-
// CHECK: attributes #[[sve2_sm4]] = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+outline-atomics,+sm4,+sve,+sve2,+sve2-sm4,+v8a"
192+
// CHECK: attributes #[[sve2_sm4]] = { {{.*}} "target-features"="+fp-armv8,+fullfp16,+neon,+outline-atomics,+sm4,+sve,+sve-sm4,+sve2,+sve2-sm4,+v8a"
193193
// CHECK: attributes #[[wfxt]] = { {{.*}} "target-features"="+fp-armv8,+neon,+outline-atomics,+v8a,+wfxt"
194194
// CHECK: attributes #[[cssc]] = { {{.*}} "target-features"="+cssc,+fp-armv8,+neon,+outline-atomics,+v8a"

clang/test/Driver/aarch64-implied-sve-features.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
// SVE2-SHA3-REVERT: "-target-feature" "+sve" "-target-feature" "-sve-sha3" "-target-feature" "+sve2" "-target-feature" "-sve2-sha3"
5050

5151
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sm4+nosve2-sm4 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SM4-REVERT
52-
// SVE2-SM4-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "-sve2-sm4"
52+
// SVE2-SM4-REVERT: "-target-feature" "+sve" "-target-feature" "-sve-sm4" "-target-feature" "+sve2" "-target-feature" "-sve2-sm4"
5353

5454
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sha3 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SHA3
5555
// SVE2-SHA3: "-target-feature" "+sve" "-target-feature" "+sve-sha3" "-target-feature" "+sve2" "-target-feature" "+sve2-sha3"
@@ -61,14 +61,14 @@
6161
// SVE2-AES: "-target-feature" "+sve" "-target-feature" "+sve-aes" "-target-feature" "+sve2" "-target-feature" "+sve2-aes"
6262

6363
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sm4 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SM4
64-
// SVE2-SM4: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+sve2-sm4"
64+
// SVE2-SM4: "-target-feature" "+sve" "-target-feature" "+sve-sm4" "-target-feature" "+sve2" "-target-feature" "+sve2-sm4"
6565

6666
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-bitperm+nosve2-aes %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SUBFEATURE-MIX
6767
// SVE2-SUBFEATURE-MIX: "-target-feature" "+sve" "-target-feature" "+sve-bitperm" "-target-feature" "+sve2" "-target-feature" "+sve2-bitperm"
6868
// SVE2-SUBFEATURE-NOT: sve2-aes
6969

7070
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sm4+nosve2 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SUBFEATURE-CONFLICT
71-
// SVE2-SUBFEATURE-CONFLICT: "-target-feature" "+sve" "-target-feature" "-sve2" "-target-feature" "-sve2-sm4"
71+
// SVE2-SUBFEATURE-CONFLICT: "-target-feature" "+sve" "-target-feature" "-sve-sm4" "-target-feature" "-sve2" "-target-feature" "-sve2-sm4"
7272

7373
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-aes+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT
7474
// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve2-aes"

clang/test/Driver/print-enabled-extensions/aarch64-fujitsu-monaka.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
// CHECK-NEXT: FEAT_SVE_AES, FEAT_SVE_PMULL128 Enable SVE AES and quadword SVE polynomial multiply instructions
7272
// CHECK-NEXT: FEAT_SVE_BitPerm Enable bit permutation SVE2 instructions
7373
// CHECK-NEXT: FEAT_SVE_SHA3 Enable SVE SHA3 instructions
74-
// CHECK-NEXT: FEAT_SVE_SM4 Enable SM4 SVE2 instructions
74+
// CHECK-NEXT: FEAT_SVE_SM4 Enable SVE SM4 instructions
7575
// CHECK-NEXT: FEAT_TLBIOS, FEAT_TLBIRANGE Enable Armv8.4-A TLB Range and Maintenance instructions
7676
// CHECK-NEXT: FEAT_TRBE Enable Trace Buffer Extension
7777
// CHECK-NEXT: FEAT_TRF Enable Armv8.4-A Trace extension

clang/test/Driver/print-enabled-extensions/aarch64-gb10.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
// CHECK-NEXT: FEAT_SVE_AES, FEAT_SVE_PMULL128 Enable SVE AES and quadword SVE polynomial multiply instructions
6060
// CHECK-NEXT: FEAT_SVE_BitPerm Enable bit permutation SVE2 instructions
6161
// CHECK-NEXT: FEAT_SVE_SHA3 Enable SVE SHA3 instructions
62-
// CHECK-NEXT: FEAT_SVE_SM4 Enable SM4 SVE2 instructions
62+
// CHECK-NEXT: FEAT_SVE_SM4 Enable SVE SM4 instructions
6363
// CHECK-NEXT: FEAT_TLBIOS, FEAT_TLBIRANGE Enable Armv8.4-A TLB Range and Maintenance instructions
6464
// CHECK-NEXT: FEAT_TRBE Enable Trace Buffer Extension
6565
// CHECK-NEXT: FEAT_TRF Enable Armv8.4-A Trace extension

clang/test/Driver/print-enabled-extensions/aarch64-grace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
// CHECK-NEXT: FEAT_SVE_AES, FEAT_SVE_PMULL128 Enable SVE AES and quadword SVE polynomial multiply instructions
5656
// CHECK-NEXT: FEAT_SVE_BitPerm Enable bit permutation SVE2 instructions
5757
// CHECK-NEXT: FEAT_SVE_SHA3 Enable SVE SHA3 instructions
58-
// CHECK-NEXT: FEAT_SVE_SM4 Enable SM4 SVE2 instructions
58+
// CHECK-NEXT: FEAT_SVE_SM4 Enable SVE SM4 instructions
5959
// CHECK-NEXT: FEAT_TLBIOS, FEAT_TLBIRANGE Enable Armv8.4-A TLB Range and Maintenance instructions
6060
// CHECK-NEXT: FEAT_TRBE Enable Trace Buffer Extension
6161
// CHECK-NEXT: FEAT_TRF Enable Armv8.4-A Trace extension

clang/test/Driver/print-enabled-extensions/aarch64-olympus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
// CHECK-NEXT: FEAT_SVE_AES, FEAT_SVE_PMULL128 Enable SVE AES and quadword SVE polynomial multiply instructions
7272
// CHECK-NEXT: FEAT_SVE_BitPerm Enable bit permutation SVE2 instructions
7373
// CHECK-NEXT: FEAT_SVE_SHA3 Enable SVE SHA3 instructions
74-
// CHECK-NEXT: FEAT_SVE_SM4 Enable SM4 SVE2 instructions
74+
// CHECK-NEXT: FEAT_SVE_SM4 Enable SVE SM4 instructions
7575
// CHECK-NEXT: FEAT_TLBIOS, FEAT_TLBIRANGE Enable Armv8.4-A TLB Range and Maintenance instructions
7676
// CHECK-NEXT: FEAT_TRBE Enable Trace Buffer Extension
7777
// CHECK-NEXT: FEAT_TRF Enable Armv8.4-A Trace extension

clang/test/Driver/print-supported-extensions-aarch64.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@
9393
// CHECK-NEXT: sve-bitperm FEAT_SVE_BitPerm Enable bit permutation SVE2 instructions
9494
// CHECK-NEXT: sve-f16f32mm FEAT_SVE_F16F32MM Enable Armv9.6-A FP16 to FP32 Matrix Multiply
9595
// CHECK-NEXT: sve-sha3 FEAT_SVE_SHA3 Enable SVE SHA3 instructions
96+
// CHECK-NEXT: sve-sm4 FEAT_SVE_SM4 Enable SVE SM4 instructions
9697
// CHECK-NEXT: sve2 FEAT_SVE2 Enable Scalable Vector Extension 2 (SVE2) instructions
9798
// CHECK-NEXT: sve2-aes Shorthand for +sve2+sve-aes
9899
// CHECK-NEXT: sve2-bitperm Shorthand for +sve2+sve-bitperm
99100
// CHECK-NEXT: sve2-sha3 Shorthand for +sve2+sve-sha3
100-
// CHECK-NEXT: sve2-sm4 FEAT_SVE_SM4 Enable SM4 SVE2 instructions
101+
// CHECK-NEXT: sve2-sm4 Shorthand for +sve2+sve-sm4
101102
// CHECK-NEXT: sve2p1 FEAT_SVE2p1 Enable Scalable Vector Extension 2.1 instructions
102103
// CHECK-NEXT: sve2p2 FEAT_SVE2p2 Enable Armv9.6-A Scalable Vector Extension 2.2 instructions
103104
// CHECK-NEXT: the FEAT_THE Enable Armv8.9-A Translation Hardening Extension

llvm/lib/Target/AArch64/AArch64.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def SVE2p1Unsupported : AArch64Unsupported;
6363

6464
def SVE2Unsupported : AArch64Unsupported {
6565
let F = !listconcat([HasSVE2, HasSVE2_or_SME, HasNonStreamingSVE2_or_SME2, HasSSVE_FP8FMA, HasSMEF8F16,
66-
HasSMEF8F32, HasSVEAES, HasSVESHA3, HasSVE2SM4, HasSVEBitPerm,
66+
HasSMEF8F32, HasSVEAES, HasSVESHA3, HasSVESM4, HasSVEBitPerm,
6767
HasSVEB16B16],
6868
SVE2p1Unsupported.F);
6969
}

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,11 @@ def FeatureSVEAES : ExtensionWithMArch<"sve-aes", "SVEAES",
370370
def FeatureAliasSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES",
371371
"", "Shorthand for +sve2+sve-aes", [FeatureSVE2, FeatureSVEAES]>;
372372

373-
def FeatureSVE2SM4 : ExtensionWithMArch<"sve2-sm4", "SVE2SM4", "FEAT_SVE_SM4",
374-
"Enable SM4 SVE2 instructions", [FeatureSVE2, FeatureSM4]>;
373+
def FeatureSVESM4 : ExtensionWithMArch<"sve-sm4", "SVESM4", "FEAT_SVE_SM4",
374+
"Enable SVE SM4 instructions", [FeatureSM4]>;
375+
376+
def FeatureAliasSVE2SM4 : ExtensionWithMArch<"sve2-sm4", "SVE2SM4",
377+
"", "Shorthand for +sve2+sve-sm4", [FeatureSVE2, FeatureSVESM4]>;
375378

376379
def FeatureSVESHA3 : ExtensionWithMArch<"sve-sha3", "SVESHA3", "FEAT_SVE_SHA3",
377380
"Enable SVE SHA3 instructions", [FeatureSHA3]>;

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def HasSVE2p1 : Predicate<"Subtarget->isSVEAvailable() && Subtarget->hasS
151151
AssemblerPredicateWithAll<(all_of FeatureSVE2p1), "sve2p1">;
152152
def HasSVEAES : Predicate<"Subtarget->hasSVEAES()">,
153153
AssemblerPredicateWithAll<(all_of FeatureSVEAES), "sve-aes">;
154-
def HasSVE2SM4 : Predicate<"Subtarget->isSVEAvailable() && Subtarget->hasSVE2SM4()">,
155-
AssemblerPredicateWithAll<(all_of FeatureSVE2SM4), "sve2-sm4">;
154+
def HasSVESM4 : Predicate<"Subtarget->isSVEAvailable() && Subtarget->hasSVESM4()">,
155+
AssemblerPredicateWithAll<(all_of FeatureSVESM4), "sve-sm4">;
156156
def HasSVESHA3 : Predicate<"Subtarget->hasSVESHA3()">,
157157
AssemblerPredicateWithAll<(all_of FeatureSVESHA3), "sve-sha3">;
158158
def HasSVEBitPerm : Predicate<"Subtarget->hasSVEBitPerm()">,

0 commit comments

Comments
 (0)