-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AArch64][NEON] Add eor3 patterns for V64 xors #165376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-backend-aarch64 Author: None (Lukacma) ChangesThis patch enables NEON EOR3 instruction to be emitted even for 64 bit vectors. Full diff: https://github.com/llvm/llvm-project/pull/165376.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index b9e299ef37454..0070635ca5f12 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -1805,14 +1805,22 @@ def : SHA3_pattern<EOR3, int_aarch64_crypto_eor3u, v8i16>;
def : SHA3_pattern<EOR3, int_aarch64_crypto_eor3u, v4i32>;
def : SHA3_pattern<EOR3, int_aarch64_crypto_eor3u, v2i64>;
-class EOR3_pattern<ValueType VecTy>
- : Pat<(xor (xor (VecTy V128:$Vn), (VecTy V128:$Vm)), (VecTy V128:$Va)),
- (EOR3 (VecTy V128:$Vn), (VecTy V128:$Vm), (VecTy V128:$Va))>;
-
-def : EOR3_pattern<v16i8>;
-def : EOR3_pattern<v8i16>;
-def : EOR3_pattern<v4i32>;
-def : EOR3_pattern<v2i64>;
+multiclass EOR3_pattern<ValueType Vec128Ty, ValueType Vec64Ty>{
+ def: Pat<(xor (xor (Vec128Ty V128:$Vn), (Vec128Ty V128:$Vm)), (Vec128Ty V128:$Va)),
+ (EOR3 (Vec128Ty V128:$Vn), (Vec128Ty V128:$Vm), (Vec128Ty V128:$Va))>;
+ def : Pat<(xor (xor (Vec64Ty V64:$Vn), (Vec64Ty V64:$Vm)), (Vec64Ty V64:$Va)),
+ (EXTRACT_SUBREG
+ (EOR3
+ (INSERT_SUBREG (IMPLICIT_DEF), V64:$Vn, dsub),
+ (INSERT_SUBREG (IMPLICIT_DEF), V64:$Vm, dsub),
+ (INSERT_SUBREG (IMPLICIT_DEF), V64:$Va, dsub)),
+ dsub)>;
+}
+
+defm : EOR3_pattern<v16i8, v8i8>;
+defm : EOR3_pattern<v8i16, v4i16>;
+defm : EOR3_pattern<v4i32, v2i32>;
+defm : EOR3_pattern<v2i64, v1i64>;
class BCAX_pattern<ValueType VecTy>
: Pat<(xor (VecTy V128:$Vn), (and (VecTy V128:$Vm), (vnot (VecTy V128:$Va)))),
diff --git a/llvm/test/CodeGen/AArch64/eor3.ll b/llvm/test/CodeGen/AArch64/eor3.ll
index eccd09131b525..594a73f70a7f9 100644
--- a/llvm/test/CodeGen/AArch64/eor3.ll
+++ b/llvm/test/CodeGen/AArch64/eor3.ll
@@ -277,3 +277,154 @@ define <2 x i64> @eor3_vnot(<2 x i64> %0, <2 x i64> %1) {
ret <2 x i64> %4
}
+define <1 x i64> @eor3_1x64(<1 x i64> %0, <1 x i64> %1, <1 x i64> %2) {
+; SHA3-LABEL: eor3_1x64:
+; SHA3: // %bb.0:
+; SHA3-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-NEXT: ret
+;
+; NOSHA3-LABEL: eor3_1x64:
+; NOSHA3: // %bb.0:
+; NOSHA3-NEXT: eor v1.8b, v1.8b, v2.8b
+; NOSHA3-NEXT: eor v0.8b, v1.8b, v0.8b
+; NOSHA3-NEXT: ret
+;
+; SVE2-LABEL: eor3_1x64:
+; SVE2: // %bb.0:
+; SVE2-NEXT: // kill: def $d1 killed $d1 def $z1
+; SVE2-NEXT: // kill: def $d2 killed $d2 def $z2
+; SVE2-NEXT: // kill: def $d0 killed $d0 def $z0
+; SVE2-NEXT: eor3 z1.d, z1.d, z2.d, z0.d
+; SVE2-NEXT: fmov d0, d1
+; SVE2-NEXT: ret
+;
+; SHA3-SVE2-LABEL: eor3_1x64:
+; SHA3-SVE2: // %bb.0:
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-SVE2-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-SVE2-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-SVE2-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-SVE2-NEXT: ret
+ %4 = xor <1 x i64> %1, %2
+ %5 = xor <1 x i64> %4, %0
+ ret <1 x i64> %5
+}
+
+define <2 x i32> @eor3_2x32(<2 x i32> %0, <2 x i32> %1, <2 x i32> %2) {
+; SHA3-LABEL: eor3_2x32:
+; SHA3: // %bb.0:
+; SHA3-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-NEXT: ret
+;
+; NOSHA3-LABEL: eor3_2x32:
+; NOSHA3: // %bb.0:
+; NOSHA3-NEXT: eor v1.8b, v1.8b, v2.8b
+; NOSHA3-NEXT: eor v0.8b, v1.8b, v0.8b
+; NOSHA3-NEXT: ret
+;
+; SVE2-LABEL: eor3_2x32:
+; SVE2: // %bb.0:
+; SVE2-NEXT: // kill: def $d1 killed $d1 def $z1
+; SVE2-NEXT: // kill: def $d2 killed $d2 def $z2
+; SVE2-NEXT: // kill: def $d0 killed $d0 def $z0
+; SVE2-NEXT: eor3 z1.d, z1.d, z2.d, z0.d
+; SVE2-NEXT: fmov d0, d1
+; SVE2-NEXT: ret
+;
+; SHA3-SVE2-LABEL: eor3_2x32:
+; SHA3-SVE2: // %bb.0:
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-SVE2-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-SVE2-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-SVE2-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-SVE2-NEXT: ret
+ %4 = xor <2 x i32> %1, %2
+ %5 = xor <2 x i32> %4, %0
+ ret <2 x i32> %5
+}
+
+define <4 x i16> @eor3_4x16(<4 x i16> %0, <4 x i16> %1, <4 x i16> %2) {
+; SHA3-LABEL: eor3_4x16:
+; SHA3: // %bb.0:
+; SHA3-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-NEXT: ret
+;
+; NOSHA3-LABEL: eor3_4x16:
+; NOSHA3: // %bb.0:
+; NOSHA3-NEXT: eor v1.8b, v1.8b, v2.8b
+; NOSHA3-NEXT: eor v0.8b, v1.8b, v0.8b
+; NOSHA3-NEXT: ret
+;
+; SVE2-LABEL: eor3_4x16:
+; SVE2: // %bb.0:
+; SVE2-NEXT: // kill: def $d1 killed $d1 def $z1
+; SVE2-NEXT: // kill: def $d2 killed $d2 def $z2
+; SVE2-NEXT: // kill: def $d0 killed $d0 def $z0
+; SVE2-NEXT: eor3 z1.d, z1.d, z2.d, z0.d
+; SVE2-NEXT: fmov d0, d1
+; SVE2-NEXT: ret
+;
+; SHA3-SVE2-LABEL: eor3_4x16:
+; SHA3-SVE2: // %bb.0:
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-SVE2-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-SVE2-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-SVE2-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-SVE2-NEXT: ret
+ %4 = xor <4 x i16> %1, %2
+ %5 = xor <4 x i16> %4, %0
+ ret <4 x i16> %5
+}
+
+define <8 x i8> @eor3_8x8(<8 x i8> %0, <8 x i8> %1, <8 x i8> %2) {
+; SHA3-LABEL: eor3_8x8:
+; SHA3: // %bb.0:
+; SHA3-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-NEXT: ret
+;
+; NOSHA3-LABEL: eor3_8x8:
+; NOSHA3: // %bb.0:
+; NOSHA3-NEXT: eor v1.8b, v1.8b, v2.8b
+; NOSHA3-NEXT: eor v0.8b, v1.8b, v0.8b
+; NOSHA3-NEXT: ret
+;
+; SVE2-LABEL: eor3_8x8:
+; SVE2: // %bb.0:
+; SVE2-NEXT: // kill: def $d1 killed $d1 def $z1
+; SVE2-NEXT: // kill: def $d2 killed $d2 def $z2
+; SVE2-NEXT: // kill: def $d0 killed $d0 def $z0
+; SVE2-NEXT: eor3 z1.d, z1.d, z2.d, z0.d
+; SVE2-NEXT: fmov d0, d1
+; SVE2-NEXT: ret
+;
+; SHA3-SVE2-LABEL: eor3_8x8:
+; SHA3-SVE2: // %bb.0:
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 def $q0
+; SHA3-SVE2-NEXT: // kill: def $d2 killed $d2 def $q2
+; SHA3-SVE2-NEXT: // kill: def $d1 killed $d1 def $q1
+; SHA3-SVE2-NEXT: eor3 v0.16b, v1.16b, v2.16b, v0.16b
+; SHA3-SVE2-NEXT: // kill: def $d0 killed $d0 killed $q0
+; SHA3-SVE2-NEXT: ret
+ %4 = xor <8 x i8> %1, %2
+ %5 = xor <8 x i8> %4, %0
+ ret <8 x i8> %5
+}
|
jthackray
reviewed
Oct 28, 2025
jthackray
approved these changes
Oct 28, 2025
Contributor
jthackray
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
mgabka
approved these changes
Oct 28, 2025
Co-authored-by: Jonathan Thackray <[email protected]>
aokblast
pushed a commit
to aokblast/llvm-project
that referenced
this pull request
Oct 30, 2025
This patch enables NEON EOR3 instruction to be emitted even for 64 bit vectors.
DEBADRIBASAK
pushed a commit
to DEBADRIBASAK/llvm-project
that referenced
this pull request
Nov 3, 2025
This patch enables NEON EOR3 instruction to be emitted even for 64 bit vectors.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch enables NEON EOR3 instruction to be emitted even for 64 bit vectors.