Skip to content

Commit

Permalink
xts/gcm: arm64 use VSRI/VSLI
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Sep 24, 2024
1 parent f47051e commit 25e0700
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions cipher/xts_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
\
VUSHR $63, B0.D2, T2.D2 \
VEXT $8, T2.B16, ZERO.B16, T2.B16 \
VSHL $1, B0.D2, B0.D2 \
VEOR T1.B16, B0.B16, B0.B16 \
VEOR T2.B16, B0.B16, B0.B16
VSLI $1, B0.D2, T2.D2 \
VEOR T1.B16, T2.B16, B0.B16

#define gbDoubleTweak(B0, ZERO, POLY, I, T1, T2) \
VREV64 B0.B16, B0.B16 \
Expand All @@ -37,9 +36,8 @@
\
VSHL $63, B0.D2, T2.D2 \
VEXT $8, ZERO.B16, T2.B16, T2.B16 \
VUSHR $1, B0.D2, B0.D2 \
VEOR T1.B16, B0.B16, B0.B16 \
VEOR T2.B16, B0.B16, B0.B16 \
VSRI $1, B0.D2, T2.D2 \
VEOR T1.B16, T2.B16, B0.B16 \
\
VEXT $8, B0.B16, B0.B16, B0.B16 \
VREV64 B0.B16, B0.B16
Expand Down
5 changes: 2 additions & 3 deletions sm4/gcm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ sm4InitEncDone:
VAND POLY.B16, T1.B16, T1.B16
VUSHR $63, B0.D2, T2.D2
VEXT $8, ZERO.B16, T2.B16, T2.B16
VSHL $1, B0.D2, B0.D2
VEOR T1.B16, B0.B16, B0.B16
VEOR T2.B16, B0.B16, B0.B16 // Can avoid this when VSLI is available
VSLI $1, B0.D2, T2.D2
VEOR T1.B16, T2.B16, B0.B16

// Karatsuba pre-computation
VEXT $8, B0.B16, B0.B16, B1.B16
Expand Down
10 changes: 4 additions & 6 deletions sm4/xts_macros_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
\
VUSHR $63, TW.D2, K1.D2; \
VEXT $8, K1.B16, ZERO.B16, K1.B16; \
VSHL $1, TW.D2, TW.D2; \
VEOR K0.B16, TW.B16, TW.B16; \
VEOR K1.B16, TW.B16, TW.B16
VSLI $1, TW.D2, K1.D2; \
VEOR K0.B16, K1.B16, TW.B16

#define mul2GBInline \
VREV64 TW.B16, TW.B16; \
Expand All @@ -22,9 +21,8 @@
\
VSHL $63, TW.D2, K1.D2; \
VEXT $8, ZERO.B16, K1.B16, K1.B16; \
VUSHR $1, TW.D2, TW.D2; \
VEOR K0.B16, TW.B16, TW.B16; \
VEOR K1.B16, TW.B16, TW.B16; \
VSRI $1, TW.D2, K1.D2; \
VEOR K0.B16, K1.B16, TW.B16; \
\
VEXT $8, TW.B16, TW.B16, TW.B16; \
VREV64 TW.B16, TW.B16
Expand Down

0 comments on commit 25e0700

Please sign in to comment.