Ejemplo n.º 1
0
        internal static byte16 vdiv_byte_SSE_FALLBACK(byte16 dividend, byte16 divisor)
        {
            Assert.AreNotEqual(divisor.x0, 0);
            Assert.AreNotEqual(divisor.x1, 0);
            Assert.AreNotEqual(divisor.x2, 0);
            Assert.AreNotEqual(divisor.x3, 0);
            Assert.AreNotEqual(divisor.x4, 0);
            Assert.AreNotEqual(divisor.x5, 0);
            Assert.AreNotEqual(divisor.x6, 0);
            Assert.AreNotEqual(divisor.x7, 0);
            Assert.AreNotEqual(divisor.x8, 0);
            Assert.AreNotEqual(divisor.x9, 0);
            Assert.AreNotEqual(divisor.x10, 0);
            Assert.AreNotEqual(divisor.x11, 0);
            Assert.AreNotEqual(divisor.x12, 0);
            Assert.AreNotEqual(divisor.x13, 0);
            Assert.AreNotEqual(divisor.x14, 0);
            Assert.AreNotEqual(divisor.x15, 0);

            if (Sse2.IsSse2Supported)
            {
                byte16 quotients = byte16.zero;
                byte16 remainder = byte16.zero;


                remainder |= (new byte16(1) & (dividend >> 7));

                v128 subtractDivisorFromRemainder = Sse2.cmpeq_epi8(maxmath.min(divisor, remainder), divisor);

                remainder -= Mask.BlendV(default(v128), divisor, subtractDivisorFromRemainder);
                quotients |= new byte16(1) & subtractDivisorFromRemainder;

                for (int i = 6; i > 0; i--)
                {
                    quotients <<= 1;
                    remainder <<= 1;

                    remainder |= (new byte16(1) & (dividend >> i));

                    subtractDivisorFromRemainder = Sse2.cmpeq_epi8(maxmath.min(divisor, remainder), divisor);

                    remainder -= Mask.BlendV(default(v128), divisor, subtractDivisorFromRemainder);
                    quotients |= new byte16(1) & subtractDivisorFromRemainder;
                }

                remainder <<= 1;;
                quotients <<= 1;

                remainder |= new byte16(1) & dividend;

                subtractDivisorFromRemainder = Sse2.cmpeq_epi8(maxmath.min(divisor, remainder), divisor);

                quotients |= new byte16(1) & subtractDivisorFromRemainder;


                return(quotients);
            }
            else
            {
                throw new CPUFeatureCheckException();
            }
        }