@@ -16,6 +16,12 @@ extern "C" {
1616 fn sha256msg2 ( a : i32x4 , b : i32x4 ) -> i32x4 ;
1717 #[ link_name = "llvm.x86.sha256rnds2" ]
1818 fn sha256rnds2 ( a : i32x4 , b : i32x4 , k : i32x4 ) -> i32x4 ;
19+ #[ link_name = "llvm.x86.vsha512msg1" ]
20+ fn vsha512msg1 ( a : i32x8 , b : i32x4 ) -> i32x8 ;
21+ #[ link_name = "llvm.x86.vsha512msg2" ]
22+ fn vsha512msg2 ( a : i32x8 , b : i32x8 ) -> i32x8 ;
23+ #[ link_name = "llvm.x86.vsha512rnds2" ]
24+ fn vsha512rnds2_epi64 ( a : i32x8 , b : i32x8 , c : i32x4 ) -> i32x4 ;
1925}
2026
2127#[ cfg( test) ]
@@ -118,6 +124,30 @@ pub unsafe fn _mm_sha256rnds2_epu32(a: __m128i, b: __m128i, k: __m128i) -> __m12
118124 transmute ( sha256rnds2 ( a. as_i32x4 ( ) , b. as_i32x4 ( ) , k. as_i32x4 ( ) ) )
119125}
120126
127+
128+ /// Performs an intermediate calculation for the next four SHA512 message qwords.
129+ ///
130+ /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_sha512msg1_epi64)
131+ #[ inline]
132+ #[ target_feature( enable = "sha512,avx" ) ]
133+ #[ cfg_attr( test, assert_instr( vsha512msg1) ) ]
134+ #[ unstable( feature = "sha512" , issue = "none" ) ]
135+ pub unsafe fn _mm256_sha512msg1_epi64 ( a : __m256i , b : __m128i ) -> __m256i {
136+ transmute ( vsha512msg1 ( a. as_i32x8 ( ) , b. as_i32x4 ( ) ) )
137+ }
138+
139+
140+ /// Performs the final calculation for the next four SHA512 message qwords.
141+ ///
142+ /// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_sha512msg2_epi64)
143+ #[ inline]
144+ #[ target_feature( enable = "sha512,avx" ) ]
145+ #[ cfg_attr( test, assert_instr( vsha512msg2) ) ]
146+ #[ unstable( feature = "sha512" , issue = "none" ) ]
147+ pub unsafe fn _mm256_sha512msg2_epi64 ( a : __m256i , b : __m256i ) -> __m256i {
148+ transmute ( vsha512msg2 ( a. as_i32x8 ( ) , b. as_i32x8 ( ) ) )
149+ }
150+
121151#[ cfg( test) ]
122152mod tests {
123153 use std:: {
@@ -215,4 +245,14 @@ mod tests {
215245 let r = _mm_sha256rnds2_epu32 ( a, b, k) ;
216246 assert_eq_m128i ( r, expected) ;
217247 }
248+
249+ #[ simd_test( enable = "sha512,avx" ) ]
250+ #[ allow( overflowing_literals) ]
251+ unsafe fn test_mm256_sha512msg1_epi64 ( ) {
252+ let a = _mm256_set_epi64x ( 0xe9b5dba5b5c0fbcf , 0x71374491428a2f98 , 0x0 , 0x0 ) ;
253+ let b = _mm_set_epi64x ( 0xab1c5ed5923f82a4 , 0x59f111f13956c25b ) ;
254+ let expected = _mm256_set_epi64x ( 0xeb84973fd5cda67d , 0x2857b88f406b09ee , 0x0 , 0x0 ) ;
255+ let r = _mm256_sha512msg1_epi64 ( a, b) ;
256+ assert_eq_m256i ( r, expected) ;
257+ }
218258}
0 commit comments