Skip to content

Commit 5ec3699

Browse files
committed
Replace copy_nonoverlapping() in vst1_* with write_unaligned()
1 parent dcacddc commit 5ec3699

File tree

1 file changed

+27
-132
lines changed
  • crates/core_arch/src/aarch64/neon

1 file changed

+27
-132
lines changed

crates/core_arch/src/aarch64/neon/mod.rs

Lines changed: 27 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ pub use self::generated::*;
1212
use crate::{
1313
core_arch::{arm_shared::*, simd::*, simd_llvm::*},
1414
hint::unreachable_unchecked,
15-
mem::{size_of, transmute, zeroed},
16-
ptr::copy_nonoverlapping,
15+
mem::{transmute, zeroed},
1716
};
1817
#[cfg(test)]
1918
use stdarch_test::assert_instr;
@@ -657,11 +656,7 @@ pub unsafe fn vld1q_f64(ptr: *const f64) -> float64x2_t {
657656
#[cfg_attr(test, assert_instr(str))]
658657
#[allow(clippy::cast_ptr_alignment)]
659658
pub unsafe fn vst1_s8(ptr: *mut i8, a: int8x8_t) {
660-
copy_nonoverlapping(
661-
&a as *const int8x8_t as *const i8,
662-
ptr as *mut i8,
663-
size_of::<int8x8_t>(),
664-
)
659+
core::ptr::write_unaligned(ptr.cast(), a);
665660
}
666661

667662
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -670,11 +665,7 @@ pub unsafe fn vst1_s8(ptr: *mut i8, a: int8x8_t) {
670665
#[cfg_attr(test, assert_instr(str))]
671666
#[allow(clippy::cast_ptr_alignment)]
672667
pub unsafe fn vst1q_s8(ptr: *mut i8, a: int8x16_t) {
673-
copy_nonoverlapping(
674-
&a as *const int8x16_t as *const i8,
675-
ptr as *mut i8,
676-
size_of::<int8x16_t>(),
677-
)
668+
core::ptr::write_unaligned(ptr.cast(), a);
678669
}
679670

680671
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -683,11 +674,7 @@ pub unsafe fn vst1q_s8(ptr: *mut i8, a: int8x16_t) {
683674
#[cfg_attr(test, assert_instr(str))]
684675
#[allow(clippy::cast_ptr_alignment)]
685676
pub unsafe fn vst1_s16(ptr: *mut i16, a: int16x4_t) {
686-
copy_nonoverlapping(
687-
&a as *const int16x4_t as *const i16,
688-
ptr as *mut i16,
689-
size_of::<int16x4_t>(),
690-
)
677+
core::ptr::write_unaligned(ptr.cast(), a);
691678
}
692679

693680
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -696,11 +683,7 @@ pub unsafe fn vst1_s16(ptr: *mut i16, a: int16x4_t) {
696683
#[cfg_attr(test, assert_instr(str))]
697684
#[allow(clippy::cast_ptr_alignment)]
698685
pub unsafe fn vst1q_s16(ptr: *mut i16, a: int16x8_t) {
699-
copy_nonoverlapping(
700-
&a as *const int16x8_t as *const i16,
701-
ptr as *mut i16,
702-
size_of::<int16x8_t>(),
703-
)
686+
core::ptr::write_unaligned(ptr.cast(), a);
704687
}
705688

706689
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -709,11 +692,7 @@ pub unsafe fn vst1q_s16(ptr: *mut i16, a: int16x8_t) {
709692
#[cfg_attr(test, assert_instr(str))]
710693
#[allow(clippy::cast_ptr_alignment)]
711694
pub unsafe fn vst1_s32(ptr: *mut i32, a: int32x2_t) {
712-
copy_nonoverlapping(
713-
&a as *const int32x2_t as *const i32,
714-
ptr as *mut i32,
715-
size_of::<int32x2_t>(),
716-
)
695+
core::ptr::write_unaligned(ptr.cast(), a);
717696
}
718697

719698
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -722,11 +701,7 @@ pub unsafe fn vst1_s32(ptr: *mut i32, a: int32x2_t) {
722701
#[cfg_attr(test, assert_instr(str))]
723702
#[allow(clippy::cast_ptr_alignment)]
724703
pub unsafe fn vst1q_s32(ptr: *mut i32, a: int32x4_t) {
725-
copy_nonoverlapping(
726-
&a as *const int32x4_t as *const i32,
727-
ptr as *mut i32,
728-
size_of::<int32x4_t>(),
729-
)
704+
core::ptr::write_unaligned(ptr.cast(), a);
730705
}
731706

732707
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -735,11 +710,7 @@ pub unsafe fn vst1q_s32(ptr: *mut i32, a: int32x4_t) {
735710
#[cfg_attr(test, assert_instr(str))]
736711
#[allow(clippy::cast_ptr_alignment)]
737712
pub unsafe fn vst1_s64(ptr: *mut i64, a: int64x1_t) {
738-
copy_nonoverlapping(
739-
&a as *const int64x1_t as *const i64,
740-
ptr as *mut i64,
741-
size_of::<int64x1_t>(),
742-
)
713+
core::ptr::write_unaligned(ptr.cast(), a);
743714
}
744715

745716
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -748,11 +719,7 @@ pub unsafe fn vst1_s64(ptr: *mut i64, a: int64x1_t) {
748719
#[cfg_attr(test, assert_instr(str))]
749720
#[allow(clippy::cast_ptr_alignment)]
750721
pub unsafe fn vst1q_s64(ptr: *mut i64, a: int64x2_t) {
751-
copy_nonoverlapping(
752-
&a as *const int64x2_t as *const i64,
753-
ptr as *mut i64,
754-
size_of::<int64x2_t>(),
755-
)
722+
core::ptr::write_unaligned(ptr.cast(), a);
756723
}
757724

758725
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -761,11 +728,7 @@ pub unsafe fn vst1q_s64(ptr: *mut i64, a: int64x2_t) {
761728
#[cfg_attr(test, assert_instr(str))]
762729
#[allow(clippy::cast_ptr_alignment)]
763730
pub unsafe fn vst1_u8(ptr: *mut u8, a: uint8x8_t) {
764-
copy_nonoverlapping(
765-
&a as *const uint8x8_t as *const u8,
766-
ptr as *mut u8,
767-
size_of::<uint8x8_t>(),
768-
)
731+
core::ptr::write_unaligned(ptr.cast(), a);
769732
}
770733

771734
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -774,11 +737,7 @@ pub unsafe fn vst1_u8(ptr: *mut u8, a: uint8x8_t) {
774737
#[cfg_attr(test, assert_instr(str))]
775738
#[allow(clippy::cast_ptr_alignment)]
776739
pub unsafe fn vst1q_u8(ptr: *mut u8, a: uint8x16_t) {
777-
copy_nonoverlapping(
778-
&a as *const uint8x16_t as *const u8,
779-
ptr as *mut u8,
780-
size_of::<uint8x16_t>(),
781-
)
740+
core::ptr::write_unaligned(ptr.cast(), a);
782741
}
783742

784743
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -787,11 +746,7 @@ pub unsafe fn vst1q_u8(ptr: *mut u8, a: uint8x16_t) {
787746
#[cfg_attr(test, assert_instr(str))]
788747
#[allow(clippy::cast_ptr_alignment)]
789748
pub unsafe fn vst1_u16(ptr: *mut u16, a: uint16x4_t) {
790-
copy_nonoverlapping(
791-
&a as *const uint16x4_t as *const u16,
792-
ptr as *mut u16,
793-
size_of::<uint16x4_t>(),
794-
)
749+
core::ptr::write_unaligned(ptr.cast(), a);
795750
}
796751

797752
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -800,11 +755,7 @@ pub unsafe fn vst1_u16(ptr: *mut u16, a: uint16x4_t) {
800755
#[cfg_attr(test, assert_instr(str))]
801756
#[allow(clippy::cast_ptr_alignment)]
802757
pub unsafe fn vst1q_u16(ptr: *mut u16, a: uint16x8_t) {
803-
copy_nonoverlapping(
804-
&a as *const uint16x8_t as *const u16,
805-
ptr as *mut u16,
806-
size_of::<uint16x8_t>(),
807-
)
758+
core::ptr::write_unaligned(ptr.cast(), a);
808759
}
809760

810761
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -813,11 +764,7 @@ pub unsafe fn vst1q_u16(ptr: *mut u16, a: uint16x8_t) {
813764
#[cfg_attr(test, assert_instr(str))]
814765
#[allow(clippy::cast_ptr_alignment)]
815766
pub unsafe fn vst1_u32(ptr: *mut u32, a: uint32x2_t) {
816-
copy_nonoverlapping(
817-
&a as *const uint32x2_t as *const u32,
818-
ptr as *mut u32,
819-
size_of::<uint32x2_t>(),
820-
)
767+
core::ptr::write_unaligned(ptr.cast(), a);
821768
}
822769

823770
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -826,11 +773,7 @@ pub unsafe fn vst1_u32(ptr: *mut u32, a: uint32x2_t) {
826773
#[cfg_attr(test, assert_instr(str))]
827774
#[allow(clippy::cast_ptr_alignment)]
828775
pub unsafe fn vst1q_u32(ptr: *mut u32, a: uint32x4_t) {
829-
copy_nonoverlapping(
830-
&a as *const uint32x4_t as *const u32,
831-
ptr as *mut u32,
832-
size_of::<uint32x4_t>(),
833-
)
776+
core::ptr::write_unaligned(ptr.cast(), a);
834777
}
835778

836779
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -839,11 +782,7 @@ pub unsafe fn vst1q_u32(ptr: *mut u32, a: uint32x4_t) {
839782
#[cfg_attr(test, assert_instr(str))]
840783
#[allow(clippy::cast_ptr_alignment)]
841784
pub unsafe fn vst1_u64(ptr: *mut u64, a: uint64x1_t) {
842-
copy_nonoverlapping(
843-
&a as *const uint64x1_t as *const u64,
844-
ptr as *mut u64,
845-
size_of::<uint64x1_t>(),
846-
)
785+
core::ptr::write_unaligned(ptr.cast(), a);
847786
}
848787

849788
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -852,11 +791,7 @@ pub unsafe fn vst1_u64(ptr: *mut u64, a: uint64x1_t) {
852791
#[cfg_attr(test, assert_instr(str))]
853792
#[allow(clippy::cast_ptr_alignment)]
854793
pub unsafe fn vst1q_u64(ptr: *mut u64, a: uint64x2_t) {
855-
copy_nonoverlapping(
856-
&a as *const uint64x2_t as *const u64,
857-
ptr as *mut u64,
858-
size_of::<uint64x2_t>(),
859-
)
794+
core::ptr::write_unaligned(ptr.cast(), a);
860795
}
861796

862797
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -865,11 +800,7 @@ pub unsafe fn vst1q_u64(ptr: *mut u64, a: uint64x2_t) {
865800
#[cfg_attr(test, assert_instr(str))]
866801
#[allow(clippy::cast_ptr_alignment)]
867802
pub unsafe fn vst1_p8(ptr: *mut p8, a: poly8x8_t) {
868-
copy_nonoverlapping(
869-
&a as *const poly8x8_t as *const p8,
870-
ptr as *mut p8,
871-
size_of::<poly8x8_t>(),
872-
)
803+
core::ptr::write_unaligned(ptr.cast(), a);
873804
}
874805

875806
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -878,11 +809,7 @@ pub unsafe fn vst1_p8(ptr: *mut p8, a: poly8x8_t) {
878809
#[cfg_attr(test, assert_instr(str))]
879810
#[allow(clippy::cast_ptr_alignment)]
880811
pub unsafe fn vst1q_p8(ptr: *mut p8, a: poly8x16_t) {
881-
copy_nonoverlapping(
882-
&a as *const poly8x16_t as *const p8,
883-
ptr as *mut p8,
884-
size_of::<poly8x16_t>(),
885-
)
812+
core::ptr::write_unaligned(ptr.cast(), a);
886813
}
887814

888815
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -891,11 +818,7 @@ pub unsafe fn vst1q_p8(ptr: *mut p8, a: poly8x16_t) {
891818
#[cfg_attr(test, assert_instr(str))]
892819
#[allow(clippy::cast_ptr_alignment)]
893820
pub unsafe fn vst1_p16(ptr: *mut p16, a: poly16x4_t) {
894-
copy_nonoverlapping(
895-
&a as *const poly16x4_t as *const p16,
896-
ptr as *mut p16,
897-
size_of::<poly16x4_t>(),
898-
)
821+
core::ptr::write_unaligned(ptr.cast(), a);
899822
}
900823

901824
/// Store multiple single-element structures from one, two, three, or four registers.
@@ -904,11 +827,7 @@ pub unsafe fn vst1_p16(ptr: *mut p16, a: poly16x4_t) {
904827
#[cfg_attr(test, assert_instr(str))]
905828
#[allow(clippy::cast_ptr_alignment)]
906829
pub unsafe fn vst1q_p16(ptr: *mut p16, a: poly16x8_t) {
907-
copy_nonoverlapping(
908-
&a as *const poly16x8_t as *const p16,
909-
ptr as *mut p16,
910-
size_of::<poly16x8_t>(),
911-
)
830+
core::ptr::write_unaligned(ptr.cast(), a);
912831
}
913832

914833
// Store multiple single-element structures from one, two, three, or four registers.
@@ -917,11 +836,7 @@ pub unsafe fn vst1q_p16(ptr: *mut p16, a: poly16x8_t) {
917836
#[cfg_attr(test, assert_instr(str))]
918837
#[allow(clippy::cast_ptr_alignment)]
919838
pub unsafe fn vst1_p64(ptr: *mut p64, a: poly64x1_t) {
920-
copy_nonoverlapping(
921-
&a as *const poly64x1_t as *const p64,
922-
ptr as *mut p64,
923-
size_of::<poly64x1_t>(),
924-
)
839+
core::ptr::write_unaligned(ptr.cast(), a);
925840
}
926841

927842
// Store multiple single-element structures from one, two, three, or four registers.
@@ -930,11 +845,7 @@ pub unsafe fn vst1_p64(ptr: *mut p64, a: poly64x1_t) {
930845
#[cfg_attr(test, assert_instr(str))]
931846
#[allow(clippy::cast_ptr_alignment)]
932847
pub unsafe fn vst1q_p64(ptr: *mut p64, a: poly64x2_t) {
933-
copy_nonoverlapping(
934-
&a as *const poly64x2_t as *const p64,
935-
ptr as *mut p64,
936-
size_of::<poly64x2_t>(),
937-
)
848+
core::ptr::write_unaligned(ptr.cast(), a);
938849
}
939850

940851
// Store multiple single-element structures from one, two, three, or four registers.
@@ -943,11 +854,7 @@ pub unsafe fn vst1q_p64(ptr: *mut p64, a: poly64x2_t) {
943854
#[cfg_attr(test, assert_instr(str))]
944855
#[allow(clippy::cast_ptr_alignment)]
945856
pub unsafe fn vst1_f32(ptr: *mut f32, a: float32x2_t) {
946-
copy_nonoverlapping(
947-
&a as *const float32x2_t as *const f32,
948-
ptr as *mut f32,
949-
size_of::<float32x2_t>(),
950-
)
857+
core::ptr::write_unaligned(ptr.cast(), a);
951858
}
952859

953860
// Store multiple single-element structures from one, two, three, or four registers.
@@ -956,11 +863,7 @@ pub unsafe fn vst1_f32(ptr: *mut f32, a: float32x2_t) {
956863
#[cfg_attr(test, assert_instr(str))]
957864
#[allow(clippy::cast_ptr_alignment)]
958865
pub unsafe fn vst1q_f32(ptr: *mut f32, a: float32x4_t) {
959-
copy_nonoverlapping(
960-
&a as *const float32x4_t as *const f32,
961-
ptr as *mut f32,
962-
size_of::<float32x4_t>(),
963-
)
866+
core::ptr::write_unaligned(ptr.cast(), a);
964867
}
965868

966869
// Store multiple single-element structures from one, two, three, or four registers.
@@ -969,11 +872,7 @@ pub unsafe fn vst1q_f32(ptr: *mut f32, a: float32x4_t) {
969872
#[cfg_attr(test, assert_instr(str))]
970873
#[allow(clippy::cast_ptr_alignment)]
971874
pub unsafe fn vst1_f64(ptr: *mut f64, a: float64x1_t) {
972-
copy_nonoverlapping(
973-
&a as *const float64x1_t as *const f64,
974-
ptr as *mut f64,
975-
size_of::<float64x1_t>(),
976-
)
875+
core::ptr::write_unaligned(ptr.cast(), a);
977876
}
978877

979878
// Store multiple single-element structures from one, two, three, or four registers.
@@ -982,11 +881,7 @@ pub unsafe fn vst1_f64(ptr: *mut f64, a: float64x1_t) {
982881
#[cfg_attr(test, assert_instr(str))]
983882
#[allow(clippy::cast_ptr_alignment)]
984883
pub unsafe fn vst1q_f64(ptr: *mut f64, a: float64x2_t) {
985-
copy_nonoverlapping(
986-
&a as *const float64x2_t as *const f64,
987-
ptr as *mut f64,
988-
size_of::<float64x2_t>(),
989-
)
884+
core::ptr::write_unaligned(ptr.cast(), a);
990885
}
991886

992887
/// Absolute Value (wrapping).

0 commit comments

Comments
 (0)