Skip to content

Commit 37dbe1c

Browse files
lqdAmanieu
authored andcommitted
make some const generic immediates better match their width or the intel intrinsics guide
1 parent e4c7a52 commit 37dbe1c

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

Diff for: crates/core_arch/src/x86/avx.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -787,96 +787,96 @@ pub const _CMP_TRUE_US: i32 = 0x1f;
787787

788788
/// Compares packed double-precision (64-bit) floating-point
789789
/// elements in `a` and `b` based on the comparison operand
790-
/// specified by `imm8`.
790+
/// specified by `IMM5`.
791791
///
792792
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_cmp_pd)
793793
#[inline]
794794
#[target_feature(enable = "avx,sse2")]
795-
#[cfg_attr(test, assert_instr(vcmpeqpd, IMM8 = 0))] // TODO Validate vcmppd
795+
#[cfg_attr(test, assert_instr(vcmpeqpd, IMM5 = 0))] // TODO Validate vcmppd
796796
#[rustc_legacy_const_generics(2)]
797797
#[stable(feature = "simd_x86", since = "1.27.0")]
798-
pub unsafe fn _mm_cmp_pd<const IMM8: i32>(a: __m128d, b: __m128d) -> __m128d {
799-
static_assert_imm5!(IMM8);
800-
vcmppd(a, b, IMM8 as i8)
798+
pub unsafe fn _mm_cmp_pd<const IMM5: i32>(a: __m128d, b: __m128d) -> __m128d {
799+
static_assert_imm5!(IMM5);
800+
vcmppd(a, b, IMM5 as i8)
801801
}
802802

803803
/// Compares packed double-precision (64-bit) floating-point
804804
/// elements in `a` and `b` based on the comparison operand
805-
/// specified by `imm8`.
805+
/// specified by `IMM5`.
806806
///
807807
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_cmp_pd)
808808
#[inline]
809809
#[target_feature(enable = "avx")]
810-
#[cfg_attr(test, assert_instr(vcmpeqpd, IMM8 = 0))] // TODO Validate vcmppd
810+
#[cfg_attr(test, assert_instr(vcmpeqpd, IMM5 = 0))] // TODO Validate vcmppd
811811
#[rustc_legacy_const_generics(2)]
812812
#[stable(feature = "simd_x86", since = "1.27.0")]
813-
pub unsafe fn _mm256_cmp_pd<const IMM8: i32>(a: __m256d, b: __m256d) -> __m256d {
814-
static_assert_imm5!(IMM8);
815-
vcmppd256(a, b, IMM8 as u8)
813+
pub unsafe fn _mm256_cmp_pd<const IMM5: i32>(a: __m256d, b: __m256d) -> __m256d {
814+
static_assert_imm5!(IMM5);
815+
vcmppd256(a, b, IMM5 as u8)
816816
}
817817

818818
/// Compares packed single-precision (32-bit) floating-point
819819
/// elements in `a` and `b` based on the comparison operand
820-
/// specified by `imm8`.
820+
/// specified by `IMM5`.
821821
///
822822
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_cmp_ps)
823823
#[inline]
824824
#[target_feature(enable = "avx,sse")]
825-
#[cfg_attr(test, assert_instr(vcmpeqps, IMM8 = 0))] // TODO Validate vcmpps
825+
#[cfg_attr(test, assert_instr(vcmpeqps, IMM5 = 0))] // TODO Validate vcmpps
826826
#[rustc_legacy_const_generics(2)]
827827
#[stable(feature = "simd_x86", since = "1.27.0")]
828-
pub unsafe fn _mm_cmp_ps<const IMM8: i32>(a: __m128, b: __m128) -> __m128 {
829-
static_assert_imm5!(IMM8);
830-
vcmpps(a, b, IMM8 as i8)
828+
pub unsafe fn _mm_cmp_ps<const IMM5: i32>(a: __m128, b: __m128) -> __m128 {
829+
static_assert_imm5!(IMM5);
830+
vcmpps(a, b, IMM5 as i8)
831831
}
832832

833833
/// Compares packed single-precision (32-bit) floating-point
834834
/// elements in `a` and `b` based on the comparison operand
835-
/// specified by `imm8`.
835+
/// specified by `IMM5`.
836836
///
837837
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_cmp_ps)
838838
#[inline]
839839
#[target_feature(enable = "avx")]
840-
#[cfg_attr(test, assert_instr(vcmpeqps, IMM8 = 0))] // TODO Validate vcmpps
840+
#[cfg_attr(test, assert_instr(vcmpeqps, IMM5 = 0))] // TODO Validate vcmpps
841841
#[rustc_legacy_const_generics(2)]
842842
#[stable(feature = "simd_x86", since = "1.27.0")]
843-
pub unsafe fn _mm256_cmp_ps<const IMM8: i32>(a: __m256, b: __m256) -> __m256 {
844-
static_assert_imm5!(IMM8);
845-
vcmpps256(a, b, IMM8 as u8)
843+
pub unsafe fn _mm256_cmp_ps<const IMM5: i32>(a: __m256, b: __m256) -> __m256 {
844+
static_assert_imm5!(IMM5);
845+
vcmpps256(a, b, IMM5 as u8)
846846
}
847847

848848
/// Compares the lower double-precision (64-bit) floating-point element in
849-
/// `a` and `b` based on the comparison operand specified by `imm8`,
849+
/// `a` and `b` based on the comparison operand specified by `IMM5`,
850850
/// store the result in the lower element of returned vector,
851851
/// and copies the upper element from `a` to the upper element of returned
852852
/// vector.
853853
///
854854
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_cmp_sd)
855855
#[inline]
856856
#[target_feature(enable = "avx,sse2")]
857-
#[cfg_attr(test, assert_instr(vcmpeqsd, IMM8 = 0))] // TODO Validate vcmpsd
857+
#[cfg_attr(test, assert_instr(vcmpeqsd, IMM5 = 0))] // TODO Validate vcmpsd
858858
#[rustc_legacy_const_generics(2)]
859859
#[stable(feature = "simd_x86", since = "1.27.0")]
860-
pub unsafe fn _mm_cmp_sd<const IMM8: i32>(a: __m128d, b: __m128d) -> __m128d {
861-
static_assert_imm5!(IMM8);
862-
vcmpsd(a, b, IMM8 as i8)
860+
pub unsafe fn _mm_cmp_sd<const IMM5: i32>(a: __m128d, b: __m128d) -> __m128d {
861+
static_assert_imm5!(IMM5);
862+
vcmpsd(a, b, IMM5 as i8)
863863
}
864864

865865
/// Compares the lower single-precision (32-bit) floating-point element in
866-
/// `a` and `b` based on the comparison operand specified by `imm8`,
866+
/// `a` and `b` based on the comparison operand specified by `IMM5`,
867867
/// store the result in the lower element of returned vector,
868868
/// and copies the upper 3 packed elements from `a` to the upper elements of
869869
/// returned vector.
870870
///
871871
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_cmp_ss)
872872
#[inline]
873873
#[target_feature(enable = "avx,sse")]
874-
#[cfg_attr(test, assert_instr(vcmpeqss, IMM8 = 0))] // TODO Validate vcmpss
874+
#[cfg_attr(test, assert_instr(vcmpeqss, IMM5 = 0))] // TODO Validate vcmpss
875875
#[rustc_legacy_const_generics(2)]
876876
#[stable(feature = "simd_x86", since = "1.27.0")]
877-
pub unsafe fn _mm_cmp_ss<const IMM8: i32>(a: __m128, b: __m128) -> __m128 {
878-
static_assert_imm5!(IMM8);
879-
vcmpss(a, b, IMM8 as i8)
877+
pub unsafe fn _mm_cmp_ss<const IMM5: i32>(a: __m128, b: __m128) -> __m128 {
878+
static_assert_imm5!(IMM5);
879+
vcmpss(a, b, IMM5 as i8)
880880
}
881881

882882
/// Converts packed 32-bit integers in `a` to packed double-precision (64-bit)

Diff for: crates/core_arch/src/x86/avx2.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -3734,7 +3734,7 @@ pub unsafe fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i {
37343734
transmute(simd_xor(a.as_i64x4(), b.as_i64x4()))
37353735
}
37363736

3737-
/// Extracts an 8-bit integer from `a`, selected with `imm8`. Returns a 32-bit
3737+
/// Extracts an 8-bit integer from `a`, selected with `INDEX`. Returns a 32-bit
37383738
/// integer containing the zero-extended integer data.
37393739
///
37403740
/// See [LLVM commit D20468](https://reviews.llvm.org/D20468).
@@ -3745,12 +3745,12 @@ pub unsafe fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i {
37453745
// This intrinsic has no corresponding instruction.
37463746
#[rustc_legacy_const_generics(1)]
37473747
#[stable(feature = "simd_x86", since = "1.27.0")]
3748-
pub unsafe fn _mm256_extract_epi8<const IMM8: i32>(a: __m256i) -> i32 {
3749-
static_assert_imm5!(IMM8);
3750-
simd_extract::<_, u8>(a.as_u8x32(), IMM8 as u32) as i32
3748+
pub unsafe fn _mm256_extract_epi8<const INDEX: i32>(a: __m256i) -> i32 {
3749+
static_assert_imm5!(INDEX);
3750+
simd_extract::<_, u8>(a.as_u8x32(), INDEX as u32) as i32
37513751
}
37523752

3753-
/// Extracts a 16-bit integer from `a`, selected with `imm8`. Returns a 32-bit
3753+
/// Extracts a 16-bit integer from `a`, selected with `INDEX`. Returns a 32-bit
37543754
/// integer containing the zero-extended integer data.
37553755
///
37563756
/// See [LLVM commit D20468](https://reviews.llvm.org/D20468).
@@ -3761,22 +3761,22 @@ pub unsafe fn _mm256_extract_epi8<const IMM8: i32>(a: __m256i) -> i32 {
37613761
// This intrinsic has no corresponding instruction.
37623762
#[rustc_legacy_const_generics(1)]
37633763
#[stable(feature = "simd_x86", since = "1.27.0")]
3764-
pub unsafe fn _mm256_extract_epi16<const IMM8: i32>(a: __m256i) -> i32 {
3765-
static_assert_imm4!(IMM8);
3766-
simd_extract::<_, u16>(a.as_u16x16(), IMM8 as u32) as i32
3764+
pub unsafe fn _mm256_extract_epi16<const INDEX: i32>(a: __m256i) -> i32 {
3765+
static_assert_imm4!(INDEX);
3766+
simd_extract::<_, u16>(a.as_u16x16(), INDEX as u32) as i32
37673767
}
37683768

3769-
/// Extracts a 32-bit integer from `a`, selected with `imm8`.
3769+
/// Extracts a 32-bit integer from `a`, selected with `INDEX`.
37703770
///
37713771
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm256_extract_epi32)
37723772
#[inline]
37733773
#[target_feature(enable = "avx2")]
37743774
// This intrinsic has no corresponding instruction.
37753775
#[rustc_legacy_const_generics(1)]
37763776
#[stable(feature = "simd_x86", since = "1.27.0")]
3777-
pub unsafe fn _mm256_extract_epi32<const IMM8: i32>(a: __m256i) -> i32 {
3778-
static_assert_imm3!(IMM8);
3779-
simd_extract(a.as_i32x8(), IMM8 as u32)
3777+
pub unsafe fn _mm256_extract_epi32<const INDEX: i32>(a: __m256i) -> i32 {
3778+
static_assert_imm3!(INDEX);
3779+
simd_extract(a.as_i32x8(), INDEX as u32)
37803780
}
37813781

37823782
/// Returns the first element of the input vector of `[4 x double]`.

0 commit comments

Comments
 (0)