Skip to content

Commit 6072d4e

Browse files
committed
Ensure simd_funnel_sh{l,r} always gets passed shift amounts in range
1 parent 583827f commit 6072d4e

File tree

2 files changed

+210
-30
lines changed

2 files changed

+210
-30
lines changed

crates/core_arch/src/x86/avx512f.rs

Lines changed: 84 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21152,7 +21152,13 @@ pub fn _mm_maskz_srav_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i
2115221152
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2115321153
#[cfg_attr(test, assert_instr(vprolvd))]
2115421154
pub fn _mm512_rolv_epi32(a: __m512i, b: __m512i) -> __m512i {
21155-
unsafe { transmute(simd_funnel_shl(a.as_u32x16(), a.as_u32x16(), b.as_u32x16())) }
21155+
unsafe {
21156+
transmute(simd_funnel_shl(
21157+
a.as_u32x16(),
21158+
a.as_u32x16(),
21159+
simd_and(b.as_u32x16(), u32x16::splat(31)),
21160+
))
21161+
}
2115621162
}
2115721163

2115821164
/// Rotate the bits in each packed 32-bit integer in a to the left by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21191,7 +21197,13 @@ pub fn _mm512_maskz_rolv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i
2119121197
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2119221198
#[cfg_attr(test, assert_instr(vprolvd))]
2119321199
pub fn _mm256_rolv_epi32(a: __m256i, b: __m256i) -> __m256i {
21194-
unsafe { transmute(simd_funnel_shl(a.as_u32x8(), a.as_u32x8(), b.as_u32x8())) }
21200+
unsafe {
21201+
transmute(simd_funnel_shl(
21202+
a.as_u32x8(),
21203+
a.as_u32x8(),
21204+
simd_and(b.as_u32x8(), u32x8::splat(31)),
21205+
))
21206+
}
2119521207
}
2119621208

2119721209
/// Rotate the bits in each packed 32-bit integer in a to the left by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21230,7 +21242,13 @@ pub fn _mm256_maskz_rolv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i {
2123021242
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2123121243
#[cfg_attr(test, assert_instr(vprolvd))]
2123221244
pub fn _mm_rolv_epi32(a: __m128i, b: __m128i) -> __m128i {
21233-
unsafe { transmute(simd_funnel_shl(a.as_u32x4(), a.as_u32x4(), b.as_u32x4())) }
21245+
unsafe {
21246+
transmute(simd_funnel_shl(
21247+
a.as_u32x4(),
21248+
a.as_u32x4(),
21249+
simd_and(b.as_u32x4(), u32x4::splat(31)),
21250+
))
21251+
}
2123421252
}
2123521253

2123621254
/// Rotate the bits in each packed 32-bit integer in a to the left by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21269,7 +21287,13 @@ pub fn _mm_maskz_rolv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i {
2126921287
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2127021288
#[cfg_attr(test, assert_instr(vprorvd))]
2127121289
pub fn _mm512_rorv_epi32(a: __m512i, b: __m512i) -> __m512i {
21272-
unsafe { transmute(simd_funnel_shr(a.as_u32x16(), a.as_u32x16(), b.as_u32x16())) }
21290+
unsafe {
21291+
transmute(simd_funnel_shr(
21292+
a.as_u32x16(),
21293+
a.as_u32x16(),
21294+
simd_and(b.as_u32x16(), u32x16::splat(31)),
21295+
))
21296+
}
2127321297
}
2127421298

2127521299
/// Rotate the bits in each packed 32-bit integer in a to the right by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21308,7 +21332,13 @@ pub fn _mm512_maskz_rorv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i
2130821332
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2130921333
#[cfg_attr(test, assert_instr(vprorvd))]
2131021334
pub fn _mm256_rorv_epi32(a: __m256i, b: __m256i) -> __m256i {
21311-
unsafe { transmute(simd_funnel_shr(a.as_u32x8(), a.as_u32x8(), b.as_u32x8())) }
21335+
unsafe {
21336+
transmute(simd_funnel_shr(
21337+
a.as_u32x8(),
21338+
a.as_u32x8(),
21339+
simd_and(b.as_u32x8(), u32x8::splat(31)),
21340+
))
21341+
}
2131221342
}
2131321343

2131421344
/// Rotate the bits in each packed 32-bit integer in a to the right by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21347,7 +21377,13 @@ pub fn _mm256_maskz_rorv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i {
2134721377
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2134821378
#[cfg_attr(test, assert_instr(vprorvd))]
2134921379
pub fn _mm_rorv_epi32(a: __m128i, b: __m128i) -> __m128i {
21350-
unsafe { transmute(simd_funnel_shr(a.as_u32x4(), a.as_u32x4(), b.as_u32x4())) }
21380+
unsafe {
21381+
transmute(simd_funnel_shr(
21382+
a.as_u32x4(),
21383+
a.as_u32x4(),
21384+
simd_and(b.as_u32x4(), u32x4::splat(31)),
21385+
))
21386+
}
2135121387
}
2135221388

2135321389
/// Rotate the bits in each packed 32-bit integer in a to the right by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21386,7 +21422,13 @@ pub fn _mm_maskz_rorv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i {
2138621422
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2138721423
#[cfg_attr(test, assert_instr(vprolvq))]
2138821424
pub fn _mm512_rolv_epi64(a: __m512i, b: __m512i) -> __m512i {
21389-
unsafe { transmute(simd_funnel_shl(a.as_u64x8(), a.as_u64x8(), b.as_u64x8())) }
21425+
unsafe {
21426+
transmute(simd_funnel_shl(
21427+
a.as_u64x8(),
21428+
a.as_u64x8(),
21429+
simd_and(b.as_u64x8(), u64x8::splat(63)),
21430+
))
21431+
}
2139021432
}
2139121433

2139221434
/// Rotate the bits in each packed 64-bit integer in a to the left by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21425,7 +21467,13 @@ pub fn _mm512_maskz_rolv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i {
2142521467
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2142621468
#[cfg_attr(test, assert_instr(vprolvq))]
2142721469
pub fn _mm256_rolv_epi64(a: __m256i, b: __m256i) -> __m256i {
21428-
unsafe { transmute(simd_funnel_shl(a.as_u64x4(), a.as_u64x4(), b.as_u64x4())) }
21470+
unsafe {
21471+
transmute(simd_funnel_shl(
21472+
a.as_u64x4(),
21473+
a.as_u64x4(),
21474+
simd_and(b.as_u64x4(), u64x4::splat(63)),
21475+
))
21476+
}
2142921477
}
2143021478

2143121479
/// Rotate the bits in each packed 64-bit integer in a to the left by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21464,7 +21512,13 @@ pub fn _mm256_maskz_rolv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i {
2146421512
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2146521513
#[cfg_attr(test, assert_instr(vprolvq))]
2146621514
pub fn _mm_rolv_epi64(a: __m128i, b: __m128i) -> __m128i {
21467-
unsafe { transmute(simd_funnel_shl(a.as_u64x2(), a.as_u64x2(), b.as_u64x2())) }
21515+
unsafe {
21516+
transmute(simd_funnel_shl(
21517+
a.as_u64x2(),
21518+
a.as_u64x2(),
21519+
simd_and(b.as_u64x2(), u64x2::splat(63)),
21520+
))
21521+
}
2146821522
}
2146921523

2147021524
/// Rotate the bits in each packed 64-bit integer in a to the left by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21503,7 +21557,13 @@ pub fn _mm_maskz_rolv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i {
2150321557
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2150421558
#[cfg_attr(test, assert_instr(vprorvq))]
2150521559
pub fn _mm512_rorv_epi64(a: __m512i, b: __m512i) -> __m512i {
21506-
unsafe { transmute(simd_funnel_shr(a.as_u64x8(), a.as_u64x8(), b.as_u64x8())) }
21560+
unsafe {
21561+
transmute(simd_funnel_shr(
21562+
a.as_u64x8(),
21563+
a.as_u64x8(),
21564+
simd_and(b.as_u64x8(), u64x8::splat(63)),
21565+
))
21566+
}
2150721567
}
2150821568

2150921569
/// Rotate the bits in each packed 64-bit integer in a to the right by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21542,7 +21602,13 @@ pub fn _mm512_maskz_rorv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i {
2154221602
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2154321603
#[cfg_attr(test, assert_instr(vprorvq))]
2154421604
pub fn _mm256_rorv_epi64(a: __m256i, b: __m256i) -> __m256i {
21545-
unsafe { transmute(simd_funnel_shr(a.as_u64x4(), a.as_u64x4(), b.as_u64x4())) }
21605+
unsafe {
21606+
transmute(simd_funnel_shr(
21607+
a.as_u64x4(),
21608+
a.as_u64x4(),
21609+
simd_and(b.as_u64x4(), u64x4::splat(63)),
21610+
))
21611+
}
2154621612
}
2154721613

2154821614
/// Rotate the bits in each packed 64-bit integer in a to the right by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
@@ -21581,7 +21647,13 @@ pub fn _mm256_maskz_rorv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i {
2158121647
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2158221648
#[cfg_attr(test, assert_instr(vprorvq))]
2158321649
pub fn _mm_rorv_epi64(a: __m128i, b: __m128i) -> __m128i {
21584-
unsafe { transmute(simd_funnel_shr(a.as_u64x2(), a.as_u64x2(), b.as_u64x2())) }
21650+
unsafe {
21651+
transmute(simd_funnel_shr(
21652+
a.as_u64x2(),
21653+
a.as_u64x2(),
21654+
simd_and(b.as_u64x2(), u64x2::splat(63)),
21655+
))
21656+
}
2158521657
}
2158621658

2158721659
/// Rotate the bits in each packed 64-bit integer in a to the right by the number of bits specified in the corresponding element of b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).

0 commit comments

Comments
 (0)