public static sbyte2x3 operator %(sbyte2x3 left, sbyte2x3 right) { if (Sse2.IsSse2Supported) { #if DEBUG sbyte8 packed_LHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(left.c0, left.c1), Sse2.unpacklo_epi16(left.c2, new sbyte2(1))); sbyte8 packed_RHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(right.c0, right.c1), Sse2.unpacklo_epi16(right.c2, new sbyte2(1))); sbyte8 rem = packed_LHS % packed_RHS; return(new sbyte2x3(rem.v2_0, rem.v2_2, rem.v2_4)); #else sbyte8 packed_LHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(left.c0, left.c1), left.c2); sbyte8 packed_RHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(right.c0, right.c1), right.c2); sbyte8 rem = packed_LHS % packed_RHS; return(new sbyte2x3(rem.v2_0, rem.v2_2, rem.v2_4)); #endif } else { return(new sbyte2x3(left.c0 % right.c0, left.c1 % right.c1, left.c2 % right.c2)); } }
public static sbyte2x3 operator /(sbyte2x3 left, sbyte2x3 right) { if (Sse2.IsSse2Supported) { #if DEBUG sbyte8 packed_LHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(left.c0, left.c1), Sse2.unpacklo_epi16(left.c2, new sbyte2(1))); sbyte8 packed_RHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(right.c0, right.c1), Sse2.unpacklo_epi16(right.c2, new sbyte2(1))); sbyte8 div = packed_LHS / packed_RHS; return(new sbyte2x3(div.v2_0, div.v2_2, div.v2_4)); #else sbyte8 packed_LHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(left.c0, left.c1), left.c2); sbyte8 packed_RHS = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(right.c0, right.c1), right.c2); sbyte8 div = packed_LHS / packed_RHS; return(new sbyte2x3(div.v2_0, div.v2_2, div.v2_4)); #endif } else { return(new sbyte2x3(left.c0 / right.c0, left.c1 / right.c1, left.c2 / right.c2)); } }
public static sbyte2x3 operator %(sbyte2x3 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { #if DEBUG sbyte8 packed = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(left.c0, left.c1), Sse2.unpacklo_epi16(left.c2, new sbyte2(1))); sbyte8 rem = packed % right; return(new sbyte2x3(rem.v2_0, rem.v2_2, rem.v2_4)); #else sbyte8 packed = Sse2.unpacklo_epi32(Sse2.unpacklo_epi16(left.c0, left.c1), left.c2); sbyte8 rem = packed % right; return(new sbyte2x3(rem.v2_0, rem.v2_2, rem.v2_4)); #endif } } return(new sbyte2x3(left.c0 % right, left.c1 % right, left.c2 % right)); }
internal static sbyte8 vrem_sbyte(sbyte8 dividend, sbyte8 divisor) { int8 castDividend = dividend; int8 castDivisor = divisor; return((sbyte8)(castDividend - ((int8)vdiv_byte_quotient(castDividend, castDivisor) * castDivisor))); }
public static byte8 lcm(sbyte8 x, sbyte8 y) { byte8 absX = (byte8)abs(x); byte8 absY = (byte8)abs(y); return((absX / gcd(absX, absY)) * absY); }
internal static sbyte8 vdivrem_sbyte(sbyte8 dividend, sbyte8 divisor, out sbyte8 remainder) { int8 castDividend = dividend; int8 castDivisor = divisor; int8 quotientCast = (int8)vdiv_byte_quotient(castDividend, castDivisor); remainder = (sbyte8)(castDividend - quotientCast * castDivisor); return((sbyte8)quotientCast); }
public static quarter8 asquarter(sbyte8 x) { if (Sse.IsSseSupported) { return((v128)x); } else { return(*(quarter8 *)&x); } }
public static sbyte8 subadd(sbyte8 a, sbyte8 b) { if (Ssse3.IsSsse3Supported) { return(a + Ssse3.sign_epi8(b, new byte8(255, 1, 255, 1, 255, 1, 255, 1))); } else { return(a - select(b, -b, new bool8(false, true, false, true, false, true, false, true))); } }
public DebuggerProxy(sbyte8 v) { x0 = v.x0; x1 = v.x1; x2 = v.x2; x3 = v.x3; x4 = v.x4; x5 = v.x5; x6 = v.x6; x7 = v.x7; }
public static sbyte8 divrem(sbyte8 dividend, sbyte divisor, out sbyte8 remainder) { if (Constant.IsConstantExpression(divisor)) { remainder = dividend % divisor; return(dividend / divisor); } else { return(divrem(dividend, (sbyte8)divisor, out remainder)); } }
public static bool8 toboolsafe(sbyte8 x) { if (Sse2.IsSse2Supported) { return((v128)clamp(x, 0, 1)); } else { sbyte8 temp = clamp(x, 0, 1); return(*(bool8 *)&temp); } }
public static bool8 ispow2(sbyte8 x) { if (Sse2.IsSse2Supported) { return(Sse2.and_si128(Sse2.and_si128(Sse2.cmpgt_epi8(x, default(v128)), Sse2.cmpeq_epi8(default(v128), x & (x - 1))), new sbyte16(1))); } else { return(new bool8(math.ispow2(x.x0), math.ispow2(x.x1), math.ispow2(x.x2), math.ispow2(x.x3), math.ispow2(x.x4), math.ispow2(x.x5), math.ispow2(x.x6), math.ispow2(x.x7))); } }
public static sbyte8 ror(sbyte8 x, sbyte8 n) { if (Sse2.IsSse2Supported) { n &= 7; return((sbyte8)(shrl((byte8)x, (byte8)n) | shl((byte8)x, (byte8)(-n & 7)))); } else { return(new sbyte8(ror(x.x0, n.x0), ror(x.x1, n.x1), ror(x.x2, n.x2), ror(x.x3, n.x3), ror(x.x4, n.x4), ror(x.x5, n.x5), ror(x.x6, n.x6), ror(x.x7, n.x7))); } }
public static sbyte2x4 operator %(sbyte2x4 left, sbyte2x4 right) { if (Sse2.IsSse2Supported) { sbyte8 div = new sbyte8(left.c0, left.c1, left.c2, left.c3) % new sbyte8(right.c0, right.c1, right.c2, right.c3); return(new sbyte2x4(div.v2_0, div.v2_2, div.v2_4, div.v2_6)); } else { return(new sbyte2x4(left.c0 % right.c0, left.c1 % right.c1, left.c2 % right.c2, left.c3 % right.c3)); } }
public static bool8 isdivisible(sbyte8 dividend, sbyte8 divisor) { Assert.AreNotEqual(0, divisor.x0); Assert.AreNotEqual(0, divisor.x1); Assert.AreNotEqual(0, divisor.x2); Assert.AreNotEqual(0, divisor.x3); Assert.AreNotEqual(0, divisor.x4); Assert.AreNotEqual(0, divisor.x5); Assert.AreNotEqual(0, divisor.x6); Assert.AreNotEqual(0, divisor.x7); return(dividend % divisor == 0); }
public static sbyte2x4 operator %(sbyte2x4 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte8 rem = new sbyte8(left.c0, left.c1, left.c2, left.c3) % right; return(new sbyte2x4(rem.v2_0, rem.v2_2, rem.v2_4, rem.v2_6)); } } return(new sbyte2x4(left.c0 % right, left.c1 % right, left.c2 % right, left.c3 % right)); }
public static sbyte2x4 operator /(sbyte2x4 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte8 div = new sbyte8(left.c0, left.c1, left.c2, left.c3) / right; return(new sbyte2x4(div.v2_0, div.v2_2, div.v2_4, div.v2_6)); } } return(new sbyte2x4(left.c0 / right, left.c1 / right, left.c2 / right, left.c3 / right)); }
public static sbyte8 nabs(sbyte8 x) { if (Ssse3.IsSsse3Supported) { return(Sse2.sub_epi8(default(v128), Ssse3.abs_epi8(x))); } else if (Sse2.IsSse2Supported) { return(Mask.BlendV(-x, x, Sse2.cmpgt_epi8(default(v128), x))); } else { return(new sbyte8((sbyte)nabs((int)x.x0), (sbyte)nabs((int)x.x1), (sbyte)nabs((int)x.x2), (sbyte)nabs((int)x.x3), (sbyte)nabs((int)x.x4), (sbyte)nabs((int)x.x5), (sbyte)nabs((int)x.x6), (sbyte)nabs((int)x.x7))); } }
public static sbyte8 sign(sbyte8 x) { if (Ssse3.IsSsse3Supported) { return(Ssse3.sign_epi8(new sbyte8(1), x)); } else if (Sse2.IsSse2Supported) { return(((sbyte8)Sse2.cmpgt_epi8(x, default(v128)) & 1) + Sse2.cmpgt_epi8(default(v128), x)); } else { return((x >> 7) | (sbyte8)((byte8)(-x) >> 7)); } }
public static sbyte8 max(sbyte8 a, sbyte8 b) { if (Sse4_1.IsSse41Supported) { return(Sse4_1.max_epi8(a, b)); } else if (Sse2.IsSse2Supported) { return(Mask.BlendV(a, b, Sse2.cmpgt_epi8(b, a))); } else { return(new sbyte8((sbyte)math.max(a.x0, b.x0), (sbyte)math.max(a.x1, b.x1), (sbyte)math.max(a.x2, b.x2), (sbyte)math.max(a.x3, b.x3), (sbyte)math.max(a.x4, b.x4), (sbyte)math.max(a.x5, b.x5), (sbyte)math.max(a.x6, b.x6), (sbyte)math.max(a.x7, b.x7))); } }
internal static sbyte8 vrem_sbyte_SSE_FALLBACK(sbyte8 dividend, sbyte8 divisor) { if (Sse2.IsSse2Supported) { byte8 remainder = vrem_byte_SSE_FALLBACK((byte8)maxmath.abs(dividend), (byte8)maxmath.abs(divisor)); byte8 mustNegate = Sse2.cmpgt_epi8(sbyte8.zero, dividend); return(Mask.BlendV(remainder, -((sbyte8)remainder), mustNegate)); } else { throw new CPUFeatureCheckException(); } }
public static sbyte8 intpow(sbyte8 x, byte8 n) { if (Sse2.IsSse2Supported) { v128 ZERO = default(v128); sbyte8 ONE = new sbyte8(1); v128 doneMask = ZERO; v128 result = ZERO; sbyte8 p = x; sbyte8 y = ONE; Loop: v128 y_times_p = y * p; y = Mask.BlendV(y, y_times_p, Sse2.cmpeq_epi8(ONE, Sse2.and_si128(ONE, n))); n >>= 1; v128 n_is_zero = Sse2.cmpeq_epi8(ZERO, n); result = Mask.BlendV(result, y, Sse2.andnot_si128(doneMask, n_is_zero)); doneMask = n_is_zero; if (-1 != doneMask.SLong0) { p *= p; goto Loop; } else { return(result); } } else { return(new sbyte8((sbyte)intpow((int)x.x0, n.x0), (sbyte)intpow((int)x.x1, n.x1), (sbyte)intpow((int)x.x2, n.x2), (sbyte)intpow((int)x.x3, n.x3), (sbyte)intpow((int)x.x4, n.x4), (sbyte)intpow((int)x.x5, n.x5), (sbyte)intpow((int)x.x6, n.x6), (sbyte)intpow((int)x.x7, n.x7))); } }
public static int csum(sbyte8 x) { if (Sse2.IsSse2Supported) { short8 cast = x; cast += Sse2.unpackhi_epi64(cast, cast); cast += Sse2.shufflelo_epi16(cast, Sse.SHUFFLE(0, 1, 2, 3)); return(Sse2.add_epi16(cast, Sse2.shufflelo_epi16(cast, Sse.SHUFFLE(0, 0, 0, 1))).SShort0); } else { return(((x.x0 + x.x1) + (x.x2 + x.x3)) + ((x.x4 + x.x5) + (x.x6 + x.x7))); } }
public static sbyte8 avg(sbyte8 x, sbyte8 y) { short8 result = ((short8)x + (short8)y); // if the intermediate sum is positive add 1 if (Sse2.IsSse2Supported) { result -= Sse2.cmpgt_epi16(result, default(v128)); } else { result += toint8(result > 0); } return((sbyte8)(result >> 1)); }
public static sbyte4x2 operator /(sbyte4x2 left, sbyte4x2 right) { if (Sse2.IsSse2Supported) { sbyte8 dividend = Sse2.unpacklo_epi32(left.c0, left.c1); sbyte8 divisor = Sse2.unpacklo_epi32(right.c0, right.c1); sbyte8 quotient = dividend / divisor; return(new sbyte4x2(quotient.v4_0, quotient.v4_4)); } else { return(new sbyte4x2(left.c0 / right.c0, left.c1 / right.c1)); } }
public static sbyte4x2 operator %(sbyte4x2 left, sbyte4x2 right) { if (Sse2.IsSse2Supported) { sbyte8 dividend = Sse2.unpacklo_epi32(left.c0, left.c1); sbyte8 divisor = Sse2.unpacklo_epi32(right.c0, right.c1); sbyte8 remainder = dividend % divisor; return(new sbyte4x2(remainder.v4_0, remainder.v4_4)); } else { return(new sbyte4x2(left.c0 % right.c0, left.c1 % right.c1)); } }
public static sbyte4x2 operator %(sbyte4x2 left, sbyte right) { if (Sse2.IsSse2Supported) { if (!Constant.IsConstantExpression(right)) { sbyte8 dividend = Sse2.unpacklo_epi32(left.c0, left.c1); sbyte8 quotient = dividend % right; return(new sbyte4x2(quotient.v4_0, quotient.v4_4)); } } return(new sbyte4x2(left.c0 % right, left.c1 % right)); }
public static sbyte8 divrem(sbyte8 dividend, sbyte8 divisor, out sbyte8 remainder) { if (Avx2.IsAvx2Supported) { return(Operator.vdivrem_sbyte(dividend, divisor, out remainder)); } else if (Sse2.IsSse2Supported) { return(Operator.vdivrem_sbyte_SSE_FALLBACK(dividend, divisor, out remainder)); } else { remainder = dividend % divisor; return(dividend / divisor); } }
internal static sbyte8 vdiv_sbyte_SSE_FALLBACK(sbyte8 dividend, sbyte8 divisor) { if (Sse2.IsSse2Supported) { byte8 quotient = vdiv_byte_SSE_FALLBACK((byte8)maxmath.abs(dividend), (byte8)maxmath.abs(divisor)); byte8 mustNegate = Sse2.xor_si128(Sse2.cmpgt_epi8(sbyte8.zero, divisor), Sse2.cmpgt_epi8(sbyte8.zero, dividend)); return(Mask.BlendV(quotient, -((sbyte8)quotient), mustNegate)); } else { throw new CPUFeatureCheckException(); } }
public static sbyte8 abs(sbyte8 x) { if (Ssse3.IsSsse3Supported) { return(Ssse3.abs_epi8(x)); } else if (Sse2.IsSse2Supported) { v128 mask = Sse2.cmpgt_epi8(default(v128), x); return((x + mask) ^ mask); } else { return(new sbyte8((sbyte)math.abs(x.x0), (sbyte)math.abs(x.x1), (sbyte)math.abs(x.x2), (sbyte)math.abs(x.x3), (sbyte)math.abs(x.x4), (sbyte)math.abs(x.x5), (sbyte)math.abs(x.x6), (sbyte)math.abs(x.x7))); } }