Skip to content

Commit fdef355

Browse files
committed
[AArch64] Mark AESD and AESE as commutative.
This come from https://discourse.llvm.org/t/combining-aes-and-xor-can-be-improved-further/77248. These instructions start out with: XOR Vd, Vn <some complicated math> The initial XOR means that they can be treated as commutative, removing some of the unnecessary mov's introduced during register allocation.
1 parent b339c88 commit fdef355

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8216,8 +8216,10 @@ defm ST4 : SIMDLdSt4SingleAliases<"st4">;
82168216
//----------------------------------------------------------------------------
82178217

82188218
let Predicates = [HasAES] in {
8219+
let isCommutable = 1 in {
82198220
def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
82208221
def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
8222+
}
82218223
def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
82228224
def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
82238225
}

llvm/test/CodeGen/AArch64/aes.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ define <16 x i8> @aese(<16 x i8> %a, <16 x i8> %b) {
1616
define <16 x i8> @aese_c(<16 x i8> %a, <16 x i8> %b) {
1717
; CHECK-LABEL: aese_c:
1818
; CHECK: // %bb.0:
19-
; CHECK-NEXT: aese v1.16b, v0.16b
20-
; CHECK-NEXT: mov v0.16b, v1.16b
19+
; CHECK-NEXT: aese v0.16b, v1.16b
2120
; CHECK-NEXT: ret
2221
%r = call <16 x i8> @llvm.aarch64.crypto.aese(<16 x i8> %b, <16 x i8> %a)
2322
ret <16 x i8> %r
@@ -35,8 +34,7 @@ define <16 x i8> @aesd(<16 x i8> %a, <16 x i8> %b) {
3534
define <16 x i8> @aesd_c(<16 x i8> %a, <16 x i8> %b) {
3635
; CHECK-LABEL: aesd_c:
3736
; CHECK: // %bb.0:
38-
; CHECK-NEXT: aesd v1.16b, v0.16b
39-
; CHECK-NEXT: mov v0.16b, v1.16b
37+
; CHECK-NEXT: aesd v0.16b, v1.16b
4038
; CHECK-NEXT: ret
4139
%r = call <16 x i8> @llvm.aarch64.crypto.aesd(<16 x i8> %b, <16 x i8> %a)
4240
ret <16 x i8> %r

0 commit comments

Comments
 (0)