Skip to content

Commit c79cf82

Browse files
committed
Add inline suggestion tags to ChaCha20 SIMD wrappers
These are obviously super hot, and while LLVM shouldn't be braindead here you never know, so we might as well `#[inline]`.
1 parent e0480b5 commit c79cf82

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning/src/util/chacha20.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod real_chacha {
2121
struct u32x4(pub u32, pub u32, pub u32, pub u32);
2222
impl ::core::ops::Add for u32x4 {
2323
type Output = u32x4;
24+
#[inline]
2425
fn add(self, rhs: u32x4) -> u32x4 {
2526
u32x4(self.0.wrapping_add(rhs.0),
2627
self.1.wrapping_add(rhs.1),
@@ -30,6 +31,7 @@ mod real_chacha {
3031
}
3132
impl ::core::ops::Sub for u32x4 {
3233
type Output = u32x4;
34+
#[inline]
3335
fn sub(self, rhs: u32x4) -> u32x4 {
3436
u32x4(self.0.wrapping_sub(rhs.0),
3537
self.1.wrapping_sub(rhs.1),
@@ -39,23 +41,27 @@ mod real_chacha {
3941
}
4042
impl ::core::ops::BitXor for u32x4 {
4143
type Output = u32x4;
44+
#[inline]
4245
fn bitxor(self, rhs: u32x4) -> u32x4 {
4346
u32x4(self.0 ^ rhs.0, self.1 ^ rhs.1, self.2 ^ rhs.2, self.3 ^ rhs.3)
4447
}
4548
}
4649
impl ::core::ops::Shr<u8> for u32x4 {
4750
type Output = u32x4;
51+
#[inline]
4852
fn shr(self, shr: u8) -> u32x4 {
4953
u32x4(self.0 >> shr, self.1 >> shr, self.2 >> shr, self.3 >> shr)
5054
}
5155
}
5256
impl ::core::ops::Shl<u8> for u32x4 {
5357
type Output = u32x4;
58+
#[inline]
5459
fn shl(self, shl: u8) -> u32x4 {
5560
u32x4(self.0 << shl, self.1 << shl, self.2 << shl, self.3 << shl)
5661
}
5762
}
5863
impl u32x4 {
64+
#[inline]
5965
fn from_bytes(bytes: &[u8]) -> Self {
6066
assert_eq!(bytes.len(), 4*4);
6167
Self (

0 commit comments

Comments
 (0)