Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Xor()

unsafe BitArray System.Collections.BitArray.Xor ( BitArray value)
inline

Definition at line 559 of file BitArray.cs.

560 {
561 if (value == null)
562 {
563 throw new ArgumentNullException("value");
564 }
565 int[] array = m_array;
566 int[] array2 = value.m_array;
567 int int32ArrayLengthFromBitLength = GetInt32ArrayLengthFromBitLength(Length);
568 if (Length != value.Length || (uint)int32ArrayLengthFromBitLength > (uint)array.Length || (uint)int32ArrayLengthFromBitLength > (uint)array2.Length)
569 {
571 }
572 switch (int32ArrayLengthFromBitLength)
573 {
574 case 7:
575 array[6] ^= array2[6];
576 goto case 6;
577 case 6:
578 array[5] ^= array2[5];
579 goto case 5;
580 case 5:
581 array[4] ^= array2[4];
582 goto case 4;
583 case 4:
584 array[3] ^= array2[3];
585 goto case 3;
586 case 3:
587 array[2] ^= array2[2];
588 goto case 2;
589 case 2:
590 array[1] ^= array2[1];
591 goto case 1;
592 case 1:
593 array[0] ^= array2[0];
594 break;
595 default:
596 {
597 uint num = 0u;
598 if (Avx2.IsSupported)
599 {
600 fixed (int* ptr = m_array)
601 {
602 fixed (int* ptr2 = value.m_array)
603 {
604 for (; num < (uint)(int32ArrayLengthFromBitLength - 7); num += 8)
605 {
606 Vector256<int> left = Avx.LoadVector256(ptr + num);
607 Vector256<int> right = Avx.LoadVector256(ptr2 + num);
608 Avx.Store(ptr + num, Avx2.Xor(left, right));
609 }
610 }
611 }
612 }
613 else if (Sse2.IsSupported)
614 {
615 fixed (int* ptr3 = array)
616 {
617 fixed (int* ptr4 = array2)
618 {
619 for (; num < (uint)(int32ArrayLengthFromBitLength - 3); num += 4)
620 {
621 Vector128<int> left2 = Sse2.LoadVector128(ptr3 + num);
622 Vector128<int> right2 = Sse2.LoadVector128(ptr4 + num);
623 Sse2.Store(ptr3 + num, Sse2.Xor(left2, right2));
624 }
625 }
626 }
627 }
628 else if (AdvSimd.IsSupported)
629 {
630 fixed (int* ptr5 = array)
631 {
632 fixed (int* ptr6 = array2)
633 {
634 for (; num < (uint)(int32ArrayLengthFromBitLength - 3); num += 4)
635 {
636 Vector128<int> left3 = AdvSimd.LoadVector128(ptr5 + num);
637 Vector128<int> right3 = AdvSimd.LoadVector128(ptr6 + num);
638 AdvSimd.Store(ptr5 + num, AdvSimd.Xor(left3, right3));
639 }
640 }
641 }
642 }
643 for (; num < (uint)int32ArrayLengthFromBitLength; num++)
644 {
645 array[num] ^= array2[num];
646 }
647 break;
648 }
649 case 0:
650 break;
651 }
652 _version++;
653 return this;
654 }
static int GetInt32ArrayLengthFromBitLength(int n)
Definition BitArray.cs:988
static unsafe void Store(byte *address, Vector64< byte > source)
Definition AdvSimd.cs:10249
static unsafe Vector128< byte > LoadVector128(byte *address)
Definition AdvSimd.cs:6034
static Vector64< byte > Xor(Vector64< byte > left, Vector64< byte > right)
Definition AdvSimd.cs:10874
static new bool IsSupported
Definition Avx2.cs:15
static Vector256< sbyte > Xor(Vector256< sbyte > left, Vector256< sbyte > right)
Definition Avx2.cs:2278
static unsafe Vector256< sbyte > LoadVector256(sbyte *address)
Definition Avx.cs:462
static unsafe void Store(sbyte *address, Vector256< sbyte > source)
Definition Avx.cs:962
static unsafe Vector128< sbyte > LoadVector128(sbyte *address)
Definition Sse2.cs:582
static Vector128< byte > Xor(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:1512
static unsafe void Store(sbyte *address, Vector128< sbyte > source)
Definition Sse2.cs:1287
static new bool IsSupported
Definition Sse2.cs:60
static string Arg_ArrayLengthsDiffer
Definition SR.cs:44
Definition SR.cs:7

References System.Collections.BitArray._version, System.SR.Arg_ArrayLengthsDiffer, System.array, System.Collections.BitArray.GetInt32ArrayLengthFromBitLength(), System.Runtime.Intrinsics.Arm.AdvSimd.IsSupported, System.Runtime.Intrinsics.X86.Avx2.IsSupported, System.Runtime.Intrinsics.X86.Sse2.IsSupported, System.Collections.BitArray.Length, System.Runtime.Intrinsics.Arm.AdvSimd.LoadVector128(), System.Runtime.Intrinsics.X86.Sse2.LoadVector128(), System.Runtime.Intrinsics.X86.Avx.LoadVector256(), System.Collections.BitArray.m_array, System.Runtime.Intrinsics.Arm.AdvSimd.Store(), System.Runtime.Intrinsics.X86.Sse2.Store(), System.Runtime.Intrinsics.X86.Avx.Store(), System.value, System.Runtime.Intrinsics.X86.Sse2.Xor(), System.Runtime.Intrinsics.X86.Avx2.Xor(), and System.Runtime.Intrinsics.Arm.AdvSimd.Xor().