Commit 17e3fcc3a5

Jacob Young <jacobly0@users.noreply.github.com>
2023-08-19 09:32:47
compiler_rt: fight off `@as` invasion
Importantly, fixes incorrectly annotated types in `__aeabi_?2h`.
1 parent d653188
lib/compiler_rt/addf3.zig
@@ -9,7 +9,6 @@ const normalize = common.normalize;
 pub inline fn addf3(comptime T: type, a: T, b: T) T {
     const bits = @typeInfo(T).Float.bits;
     const Z = std.meta.Int(.unsigned, bits);
-    const S = std.meta.Int(.unsigned, bits - @clz(@as(Z, bits) - 1));
 
     const typeWidth = bits;
     const significandBits = math.floatMantissaBits(T);
@@ -26,12 +25,12 @@ pub inline fn addf3(comptime T: type, a: T, b: T) T {
     const absMask = signBit - 1;
     const qnanRep = @as(Z, @bitCast(math.nan(T))) | quietBit;
 
-    var aRep = @as(Z, @bitCast(a));
-    var bRep = @as(Z, @bitCast(b));
+    var aRep: Z = @bitCast(a);
+    var bRep: Z = @bitCast(b);
     const aAbs = aRep & absMask;
     const bAbs = bRep & absMask;
 
-    const infRep = @as(Z, @bitCast(math.inf(T)));
+    const infRep: Z = @bitCast(math.inf(T));
 
     // Detect if a or b is zero, infinity, or NaN.
     if (aAbs -% @as(Z, 1) >= infRep - @as(Z, 1) or
@@ -104,8 +103,8 @@ pub inline fn addf3(comptime T: type, a: T, b: T) T {
     const @"align": u32 = @intCast(aExponent - bExponent);
     if (@"align" != 0) {
         if (@"align" < typeWidth) {
-            const sticky = if (bSignificand << @as(S, @intCast(typeWidth - @"align")) != 0) @as(Z, 1) else 0;
-            bSignificand = (bSignificand >> @as(S, @truncate(@"align"))) | sticky;
+            const sticky = if (bSignificand << @intCast(typeWidth - @"align") != 0) @as(Z, 1) else 0;
+            bSignificand = (bSignificand >> @truncate(@"align")) | sticky;
         } else {
             bSignificand = 1; // sticky; b is known to be non-zero.
         }
@@ -119,7 +118,7 @@ pub inline fn addf3(comptime T: type, a: T, b: T) T {
         // and adjust the exponent:
         if (aSignificand < integerBit << 3) {
             const shift = @as(i32, @intCast(@clz(aSignificand))) - @as(i32, @intCast(@clz(integerBit << 3)));
-            aSignificand <<= @as(S, @intCast(shift));
+            aSignificand <<= @intCast(shift);
             aExponent -= shift;
         }
     } else { // addition
@@ -140,7 +139,7 @@ pub inline fn addf3(comptime T: type, a: T, b: T) T {
     if (aExponent <= 0) {
         // Result is denormal; the exponent and round/sticky bits are zero.
         // All we need to do is shift the significand and apply the correct sign.
-        aSignificand >>= @as(S, @intCast(4 - aExponent));
+        aSignificand >>= @intCast(4 - aExponent);
         return @bitCast(resultSign | aSignificand);
     }
 
lib/compiler_rt/ceil.zig
@@ -43,7 +43,7 @@ pub fn ceilf(x: f32) callconv(.C) f32 {
     if (e >= 23) {
         return x;
     } else if (e >= 0) {
-        m = @as(u32, 0x007FFFFF) >> @as(u5, @intCast(e));
+        m = @as(u32, 0x007FFFFF) >> @intCast(e);
         if (u & m == 0) {
             return x;
         }
lib/compiler_rt/clear_cache.zig
@@ -102,7 +102,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
         // If CTR_EL0.IDC is set, data cache cleaning to the point of unification
         // is not required for instruction to data coherence.
         if (((ctr_el0 >> 28) & 0x1) == 0x0) {
-            const dcache_line_size: usize = @as(usize, 4) << @as(u6, @intCast((ctr_el0 >> 16) & 15));
+            const dcache_line_size = @as(usize, 4) << @intCast((ctr_el0 >> 16) & 15);
             addr = start & ~(dcache_line_size - 1);
             while (addr < end) : (addr += dcache_line_size) {
                 asm volatile ("dc cvau, %[addr]"
@@ -115,7 +115,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
         // If CTR_EL0.DIC is set, instruction cache invalidation to the point of
         // unification is not required for instruction to data coherence.
         if (((ctr_el0 >> 29) & 0x1) == 0x0) {
-            const icache_line_size: usize = @as(usize, 4) << @as(u6, @intCast((ctr_el0 >> 0) & 15));
+            const icache_line_size = @as(usize, 4) << @intCast((ctr_el0 >> 0) & 15);
             addr = start & ~(icache_line_size - 1);
             while (addr < end) : (addr += icache_line_size) {
                 asm volatile ("ic ivau, %[addr]"
lib/compiler_rt/common.zig
@@ -102,14 +102,14 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
         u16 => {
             // 16x16 --> 32 bit multiply
             const product = @as(u32, a) * @as(u32, b);
-            hi.* = @as(u16, @intCast(product >> 16));
-            lo.* = @as(u16, @truncate(product));
+            hi.* = @intCast(product >> 16);
+            lo.* = @truncate(product);
         },
         u32 => {
             // 32x32 --> 64 bit multiply
             const product = @as(u64, a) * @as(u64, b);
-            hi.* = @as(u32, @truncate(product >> 32));
-            lo.* = @as(u32, @truncate(product));
+            hi.* = @truncate(product >> 32);
+            lo.* = @truncate(product);
         },
         u64 => {
             const S = struct {
@@ -136,9 +136,9 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
             hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
         },
         u128 => {
-            const Word_LoMask = @as(u64, 0x00000000ffffffff);
-            const Word_HiMask = @as(u64, 0xffffffff00000000);
-            const Word_FullMask = @as(u64, 0xffffffffffffffff);
+            const Word_LoMask: u64 = 0x00000000ffffffff;
+            const Word_HiMask: u64 = 0xffffffff00000000;
+            const Word_FullMask: u64 = 0xffffffffffffffff;
             const S = struct {
                 fn Word_1(x: u128) u64 {
                     return @as(u32, @truncate(x >> 96));
@@ -229,7 +229,7 @@ pub inline fn fneg(a: anytype) @TypeOf(a) {
     } });
     const sign_bit_mask = @as(U, 1) << (bits - 1);
     const negated = @as(U, @bitCast(a)) ^ sign_bit_mask;
-    return @as(F, @bitCast(negated));
+    return @bitCast(negated);
 }
 
 /// Allows to access underlying bits as two equally sized lower and higher
lib/compiler_rt/cos.zig
@@ -25,7 +25,7 @@ comptime {
 
 pub fn __cosh(a: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(cosf(a)));
+    return @floatCast(cosf(a));
 }
 
 pub fn cosf(x: f32) callconv(.C) f32 {
lib/compiler_rt/count0bits.zig
@@ -203,12 +203,7 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 {
 }
 
 inline fn ffsXi2(comptime T: type, a: T) i32 {
-    var x = switch (@bitSizeOf(T)) {
-        32 => @as(u32, @bitCast(a)),
-        64 => @as(u64, @bitCast(a)),
-        128 => @as(u128, @bitCast(a)),
-        else => unreachable,
-    };
+    var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a);
     var n: T = 1;
     // adapted from Number of trailing zeroes (see ctzXi2)
     var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
lib/compiler_rt/divti3.zig
@@ -21,7 +21,7 @@ pub fn __divti3(a: i128, b: i128) callconv(.C) i128 {
 const v128 = @Vector(2, u64);
 
 fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
-    return @as(v128, @bitCast(div(@as(i128, @bitCast(a)), @as(i128, @bitCast(b)))));
+    return @bitCast(div(@bitCast(a), @bitCast(b)));
 }
 
 inline fn div(a: i128, b: i128) i128 {
@@ -31,7 +31,7 @@ inline fn div(a: i128, b: i128) i128 {
     const an = (a ^ s_a) -% s_a;
     const bn = (b ^ s_b) -% s_b;
 
-    const r = udivmod(u128, @as(u128, @bitCast(an)), @as(u128, @bitCast(bn)), null);
+    const r = udivmod(u128, @bitCast(an), @bitCast(bn), null);
     const s = s_a ^ s_b;
     return (@as(i128, @bitCast(r)) ^ s) -% s;
 }
lib/compiler_rt/divxf3.zig
@@ -164,8 +164,8 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
     // exponent accordingly.
     var quotient: u64 = if (quotient128 < (integerBit << 1)) b: {
         quotientExponent -= 1;
-        break :b @as(u64, @intCast(quotient128));
-    } else @as(u64, @intCast(quotient128 >> 1));
+        break :b @intCast(quotient128);
+    } else @intCast(quotient128 >> 1);
 
     // We are going to compute a residual of the form
     //
@@ -182,18 +182,18 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
     const writtenExponent = quotientExponent + exponentBias;
     if (writtenExponent >= maxExponent) {
         // If we have overflowed the exponent, return infinity.
-        return @as(T, @bitCast(infRep | quotientSign));
+        return @bitCast(infRep | quotientSign);
     } else if (writtenExponent < 1) {
         if (writtenExponent == 0) {
             // Check whether the rounded result is normal.
             if (residual > (bSignificand >> 1)) { // round
                 if (quotient == (integerBit - 1)) // If the rounded result is normal, return it
-                    return @as(T, @bitCast(@as(Z, @bitCast(std.math.floatMin(T))) | quotientSign));
+                    return @bitCast(@as(Z, @bitCast(std.math.floatMin(T))) | quotientSign);
             }
         }
         // Flush denormals to zero.  In the future, it would be nice to add
         // code to round them correctly.
-        return @as(T, @bitCast(quotientSign));
+        return @bitCast(quotientSign);
     } else {
         const round = @intFromBool(residual > (bSignificand >> 1));
         // Insert the exponent
@@ -201,7 +201,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
         // Round
         absResult +%= round;
         // Insert the sign and return
-        return @as(T, @bitCast(absResult | quotientSign | integerBit));
+        return @bitCast(absResult | quotientSign | integerBit);
     }
 }
 
lib/compiler_rt/emutls.zig
@@ -52,19 +52,19 @@ const simple_allocator = struct {
             abort();
         }
 
-        return @as([*]u8, @ptrCast(aligned_ptr));
+        return @ptrCast(aligned_ptr);
     }
 
     /// Resize a slice.
     pub fn reallocSlice(comptime T: type, slice: []T, len: usize) []T {
-        var c_ptr: *anyopaque = @as(*anyopaque, @ptrCast(slice.ptr));
+        var c_ptr: *anyopaque = @ptrCast(slice.ptr);
         var new_array: [*]T = @ptrCast(@alignCast(std.c.realloc(c_ptr, @sizeOf(T) * len) orelse abort()));
         return new_array[0..len];
     }
 
     /// Free a memory chunk allocated with simple_allocator.
     pub fn free(ptr: anytype) void {
-        std.c.free(@as(*anyopaque, @ptrCast(ptr)));
+        std.c.free(@ptrCast(ptr));
     }
 };
 
@@ -138,7 +138,7 @@ const ObjectArray = struct {
                 @memset(data[0..size], 0);
             }
 
-            self.slots[index] = @as(*anyopaque, @ptrCast(data));
+            self.slots[index] = @ptrCast(data);
         }
 
         return self.slots[index].?;
@@ -178,7 +178,7 @@ const current_thread_storage = struct {
 
     /// Set casted thread specific value.
     fn setspecific(new: ?*ObjectArray) void {
-        if (std.c.pthread_setspecific(current_thread_storage.key, @as(*anyopaque, @ptrCast(new))) != 0) {
+        if (std.c.pthread_setspecific(current_thread_storage.key, @ptrCast(new)) != 0) {
             abort();
         }
     }
@@ -278,7 +278,7 @@ const emutls_control = extern struct {
             .size = @sizeOf(T),
             .alignment = @alignOf(T),
             .object = .{ .index = 0 },
-            .default_value = @as(?*const anyopaque, @ptrCast(default_value)),
+            .default_value = @ptrCast(default_value),
         };
     }
 
lib/compiler_rt/exp.zig
@@ -27,7 +27,7 @@ comptime {
 
 pub fn __exph(a: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(expf(a)));
+    return @floatCast(expf(a));
 }
 
 pub fn expf(x_: f32) callconv(.C) f32 {
@@ -74,7 +74,7 @@ pub fn expf(x_: f32) callconv(.C) f32 {
     if (hx > 0x3EB17218) {
         // |x| > 1.5 * ln2
         if (hx > 0x3F851592) {
-            k = @intFromFloat(invln2 * x + half[@as(usize, @intCast(sign))]);
+            k = @intFromFloat(invln2 * x + half[@intCast(sign)]);
         } else {
             k = 1 - sign - sign;
         }
@@ -157,7 +157,7 @@ pub fn exp(x_: f64) callconv(.C) f64 {
     if (hx > 0x3FD62E42) {
         // |x| >= 1.5 * ln2
         if (hx > 0x3FF0A2B2) {
-            k = @intFromFloat(invln2 * x + half[@as(usize, @intCast(sign))]);
+            k = @intFromFloat(invln2 * x + half[@intCast(sign)]);
         } else {
             k = 1 - sign - sign;
         }
lib/compiler_rt/exp2.zig
@@ -27,7 +27,7 @@ comptime {
 
 pub fn __exp2h(x: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(exp2f(x)));
+    return @floatCast(exp2f(x));
 }
 
 pub fn exp2f(x: f32) callconv(.C) f32 {
@@ -81,7 +81,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 {
     uf -= redux;
 
     const z: f64 = x - uf;
-    var r: f64 = exp2ft[@as(usize, @intCast(i_0))];
+    var r: f64 = exp2ft[@intCast(i_0)];
     const t: f64 = r * z;
     r = r + t * (P1 + z * P2) + t * (z * z) * (P3 + z * P4);
     return @floatCast(r * uk);
@@ -149,8 +149,8 @@ pub fn exp2(x: f64) callconv(.C) f64 {
 
     // r = exp2(y) = exp2t[i_0] * p(z - eps[i])
     var z: f64 = x - uf;
-    const t: f64 = exp2dt[@as(usize, @intCast(2 * i_0))];
-    z -= exp2dt[@as(usize, @intCast(2 * i_0 + 1))];
+    const t: f64 = exp2dt[@intCast(2 * i_0)];
+    z -= exp2dt[@intCast(2 * i_0 + 1)];
     const r: f64 = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
 
     return math.scalbn(r, ik);
lib/compiler_rt/extendf.zig
@@ -9,7 +9,6 @@ pub inline fn extendf(
     const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
     const srcSigBits = std.math.floatMantissaBits(src_t);
     const dstSigBits = std.math.floatMantissaBits(dst_t);
-    const DstShift = std.math.Log2Int(dst_rep_t);
 
     // Various constants whose values follow from the type parameters.
     // Any reasonable optimizer will fold and propagate all of these.
@@ -56,9 +55,8 @@ pub inline fn extendf(
         // a is denormal.
         // renormalize the significand and clear the leading bit, then insert
         // the correct adjusted exponent in the destination type.
-        const scale: u32 = @clz(aAbs) -
-            @clz(@as(src_rep_t, srcMinNormal));
-        absResult = @as(dst_rep_t, aAbs) << @as(DstShift, @intCast(dstSigBits - srcSigBits + scale));
+        const scale: u32 = @clz(aAbs) - @clz(@as(src_rep_t, srcMinNormal));
+        absResult = @as(dst_rep_t, aAbs) << @intCast(dstSigBits - srcSigBits + scale);
         absResult ^= dstMinNormal;
         const resultExponent: u32 = dstExpBias - srcExpBias - scale + 1;
         absResult |= @as(dst_rep_t, @intCast(resultExponent)) << dstSigBits;
@@ -69,7 +67,7 @@ pub inline fn extendf(
 
     // Apply the signbit to (dst_t)abs(a).
     const result: dst_rep_t align(@alignOf(dst_t)) = absResult | @as(dst_rep_t, sign) << (dstBits - srcBits);
-    return @as(dst_t, @bitCast(result));
+    return @bitCast(result);
 }
 
 pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits)) f80 {
@@ -92,8 +90,6 @@ pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeI
     const src_qnan = 1 << (src_sig_bits - 1);
     const src_nan_code = src_qnan - 1;
 
-    const SrcShift = std.math.Log2Int(src_rep_t);
-
     var dst: std.math.F80 = undefined;
 
     // Break a into a sign and representation of the absolute value
@@ -121,12 +117,11 @@ pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeI
         // a is denormal.
         // renormalize the significand and clear the leading bit, then insert
         // the correct adjusted exponent in the destination type.
-        const scale: u16 = @clz(a_abs) -
-            @clz(@as(src_rep_t, src_min_normal));
+        const scale: u16 = @clz(a_abs) - @clz(@as(src_rep_t, src_min_normal));
 
-        dst.fraction = @as(u64, a_abs) << @as(u6, @intCast(dst_sig_bits - src_sig_bits + scale));
+        dst.fraction = @as(u64, a_abs) << @intCast(dst_sig_bits - src_sig_bits + scale);
         dst.fraction |= dst_int_bit; // bit 64 is always set for normal numbers
-        dst.exp = @truncate(a_abs >> @as(SrcShift, @intCast(src_sig_bits - scale)));
+        dst.exp = @truncate(a_abs >> @intCast(src_sig_bits - scale));
         dst.exp ^= 1;
         dst.exp |= dst_exp_bias - src_exp_bias - scale + 1;
     } else {
lib/compiler_rt/extendxftf2.zig
@@ -39,12 +39,12 @@ fn __extendxftf2(a: f80) callconv(.C) f128 {
         // renormalize the significand and clear the leading bit and integer part,
         // then insert the correct adjusted exponent in the destination type.
         const scale: u32 = @clz(a_rep.fraction);
-        abs_result = @as(u128, a_rep.fraction) << @as(u7, @intCast(dst_sig_bits - src_sig_bits + scale + 1));
+        abs_result = @as(u128, a_rep.fraction) << @intCast(dst_sig_bits - src_sig_bits + scale + 1);
         abs_result ^= dst_min_normal;
         abs_result |= @as(u128, scale + 1) << dst_sig_bits;
     }
 
     // Apply the signbit to (dst_t)abs(a).
     const result: u128 align(@alignOf(f128)) = abs_result | @as(u128, sign) << (dst_bits - 16);
-    return @as(f128, @bitCast(result));
+    return @bitCast(result);
 }
lib/compiler_rt/fabs.zig
@@ -51,7 +51,7 @@ pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble {
 inline fn generic_fabs(x: anytype) @TypeOf(x) {
     const T = @TypeOf(x);
     const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
-    const float_bits = @as(TBits, @bitCast(x));
+    const float_bits: TBits = @bitCast(x);
     const remove_sign = ~@as(TBits, 0) >> 1;
-    return @as(T, @bitCast(float_bits & remove_sign));
+    return @bitCast(float_bits & remove_sign);
 }
lib/compiler_rt/fixdfti.zig
@@ -19,5 +19,5 @@ pub fn __fixdfti(a: f64) callconv(.C) i128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(i128, a)));
+    return @bitCast(intFromFloat(i128, a));
 }
lib/compiler_rt/fixhfti.zig
@@ -19,5 +19,5 @@ pub fn __fixhfti(a: f16) callconv(.C) i128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(i128, a)));
+    return @bitCast(intFromFloat(i128, a));
 }
lib/compiler_rt/fixsfti.zig
@@ -19,5 +19,5 @@ pub fn __fixsfti(a: f32) callconv(.C) i128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixsfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(i128, a)));
+    return @bitCast(intFromFloat(i128, a));
 }
lib/compiler_rt/fixtfti.zig
@@ -21,5 +21,5 @@ pub fn __fixtfti(a: f128) callconv(.C) i128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixtfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(i128, a)));
+    return @bitCast(intFromFloat(i128, a));
 }
lib/compiler_rt/fixunsdfti.zig
@@ -19,5 +19,5 @@ pub fn __fixunsdfti(a: f64) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixunsdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(u128, a)));
+    return @bitCast(intFromFloat(u128, a));
 }
lib/compiler_rt/fixunshfti.zig
@@ -19,5 +19,5 @@ pub fn __fixunshfti(a: f16) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(u128, a)));
+    return @bitCast(intFromFloat(u128, a));
 }
lib/compiler_rt/fixunssfti.zig
@@ -19,5 +19,5 @@ pub fn __fixunssfti(a: f32) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixunssfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(u128, a)));
+    return @bitCast(intFromFloat(u128, a));
 }
lib/compiler_rt/fixunstfti.zig
@@ -21,5 +21,5 @@ pub fn __fixunstfti(a: f128) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixunstfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(u128, a)));
+    return @bitCast(intFromFloat(u128, a));
 }
lib/compiler_rt/fixunsxfti.zig
@@ -19,5 +19,5 @@ pub fn __fixunsxfti(a: f80) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixunsxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(u128, a)));
+    return @bitCast(intFromFloat(u128, a));
 }
lib/compiler_rt/fixxfti.zig
@@ -19,5 +19,5 @@ pub fn __fixxfti(a: f80) callconv(.C) i128 {
 const v2u64 = @Vector(2, u64);
 
 fn __fixxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(intFromFloat(i128, a)));
+    return @bitCast(intFromFloat(i128, a));
 }
lib/compiler_rt/float_from_int.zig
@@ -28,10 +28,10 @@ pub fn floatFromInt(comptime T: type, x: anytype) T {
         const shift_amt = fractional_bits - @as(math.Log2Int(uT), @intCast(exp));
 
         // Shift up result to line up with the significand - no rounding required
-        result = (@as(uT, @intCast(abs_val)) << shift_amt);
+        result = @as(uT, @intCast(abs_val)) << shift_amt;
         result ^= implicit_bit; // Remove implicit integer bit
     } else {
-        var shift_amt = @as(math.Log2Int(Z), @intCast(exp - fractional_bits));
+        var shift_amt: math.Log2Int(Z) = @intCast(exp - fractional_bits);
         const exact_tie: bool = @ctz(abs_val) == shift_amt - 1;
 
         // Shift down result and remove implicit integer bit
@@ -43,14 +43,14 @@ pub fn floatFromInt(comptime T: type, x: anytype) T {
 
     // Compute exponent
     if ((int_bits > max_exp) and (exp > max_exp)) // If exponent too large, overflow to infinity
-        return @as(T, @bitCast(sign_bit | @as(uT, @bitCast(inf))));
+        return @bitCast(sign_bit | @as(uT, @bitCast(inf)));
 
     result += (@as(uT, exp) + exp_bias) << math.floatMantissaBits(T);
 
     // If the result included a carry, we need to restore the explicit integer bit
     if (T == f80) result |= 1 << fractional_bits;
 
-    return @as(T, @bitCast(sign_bit | result));
+    return @bitCast(sign_bit | result);
 }
 
 test {
lib/compiler_rt/float_from_int_test.zig
@@ -43,7 +43,7 @@ test "floatsisf" {
     try test__floatsisf(1, 0x3f800000);
     try test__floatsisf(-1, 0xbf800000);
     try test__floatsisf(0x7FFFFFFF, 0x4f000000);
-    try test__floatsisf(@as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), 0xcf000000);
+    try test__floatsisf(@bitCast(@as(u32, @intCast(0x80000000))), 0xcf000000);
 }
 
 test "floatunsisf" {
@@ -72,10 +72,10 @@ test "floatdisf" {
     try test__floatdisf(-2, -2.0);
     try test__floatdisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
     try test__floatdisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
-    try test__floatdisf(@as(i64, @bitCast(@as(u64, 0x8000008000000000))), -0x1.FFFFFEp+62);
-    try test__floatdisf(@as(i64, @bitCast(@as(u64, 0x8000010000000000))), -0x1.FFFFFCp+62);
-    try test__floatdisf(@as(i64, @bitCast(@as(u64, 0x8000000000000000))), -0x1.000000p+63);
-    try test__floatdisf(@as(i64, @bitCast(@as(u64, 0x8000000000000001))), -0x1.000000p+63);
+    try test__floatdisf(@bitCast(@as(u64, 0x8000008000000000)), -0x1.FFFFFEp+62);
+    try test__floatdisf(@bitCast(@as(u64, 0x8000010000000000)), -0x1.FFFFFCp+62);
+    try test__floatdisf(@bitCast(@as(u64, 0x8000000000000000)), -0x1.000000p+63);
+    try test__floatdisf(@bitCast(@as(u64, 0x8000000000000001)), -0x1.000000p+63);
     try test__floatdisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
     try test__floatdisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
     try test__floatdisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
@@ -228,7 +228,7 @@ test "floatuntisf" {
     try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBE0000000000000), 0x1.FEDCBEp+76);
 
     // Test overflow to infinity
-    try test__floatuntisf(@as(u128, math.maxInt(u128)), @as(f32, @bitCast(math.inf(f32))));
+    try test__floatuntisf(math.maxInt(u128), @bitCast(math.inf(f32)));
 }
 
 fn test_one_floatsidf(a: i32, expected: u64) !void {
@@ -246,15 +246,15 @@ test "floatsidf" {
     try test_one_floatsidf(1, 0x3ff0000000000000);
     try test_one_floatsidf(-1, 0xbff0000000000000);
     try test_one_floatsidf(0x7FFFFFFF, 0x41dfffffffc00000);
-    try test_one_floatsidf(@as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), 0xc1e0000000000000);
+    try test_one_floatsidf(@bitCast(@as(u32, @intCast(0x80000000))), 0xc1e0000000000000);
 }
 
 test "floatunsidf" {
     try test_one_floatunsidf(0, 0x0000000000000000);
     try test_one_floatunsidf(1, 0x3ff0000000000000);
     try test_one_floatunsidf(0x7FFFFFFF, 0x41dfffffffc00000);
-    try test_one_floatunsidf(@as(u32, @intCast(0x80000000)), 0x41e0000000000000);
-    try test_one_floatunsidf(@as(u32, @intCast(0xFFFFFFFF)), 0x41efffffffe00000);
+    try test_one_floatunsidf(@intCast(0x80000000), 0x41e0000000000000);
+    try test_one_floatunsidf(@intCast(0xFFFFFFFF), 0x41efffffffe00000);
 }
 
 fn test__floatdidf(a: i64, expected: f64) !void {
@@ -279,12 +279,12 @@ test "floatdidf" {
     try test__floatdidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
     try test__floatdidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
     try test__floatdidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
-    try test__floatdidf(@as(i64, @bitCast(@as(u64, @intCast(0x8000008000000000)))), -0x1.FFFFFEp+62);
-    try test__floatdidf(@as(i64, @bitCast(@as(u64, @intCast(0x8000000000000800)))), -0x1.FFFFFFFFFFFFEp+62);
-    try test__floatdidf(@as(i64, @bitCast(@as(u64, @intCast(0x8000010000000000)))), -0x1.FFFFFCp+62);
-    try test__floatdidf(@as(i64, @bitCast(@as(u64, @intCast(0x8000000000001000)))), -0x1.FFFFFFFFFFFFCp+62);
-    try test__floatdidf(@as(i64, @bitCast(@as(u64, @intCast(0x8000000000000000)))), -0x1.000000p+63);
-    try test__floatdidf(@as(i64, @bitCast(@as(u64, @intCast(0x8000000000000001)))), -0x1.000000p+63); // 0x8000000000000001
+    try test__floatdidf(@bitCast(@as(u64, @intCast(0x8000008000000000))), -0x1.FFFFFEp+62);
+    try test__floatdidf(@bitCast(@as(u64, @intCast(0x8000000000000800))), -0x1.FFFFFFFFFFFFEp+62);
+    try test__floatdidf(@bitCast(@as(u64, @intCast(0x8000010000000000))), -0x1.FFFFFCp+62);
+    try test__floatdidf(@bitCast(@as(u64, @intCast(0x8000000000001000))), -0x1.FFFFFFFFFFFFCp+62);
+    try test__floatdidf(@bitCast(@as(u64, @intCast(0x8000000000000000))), -0x1.000000p+63);
+    try test__floatdidf(@bitCast(@as(u64, @intCast(0x8000000000000001))), -0x1.000000p+63); // 0x8000000000000001
     try test__floatdidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
     try test__floatdidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
     try test__floatdidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
@@ -513,8 +513,8 @@ test "floatsitf" {
     try test__floatsitf(0x7FFFFFFF, 0x401dfffffffc00000000000000000000);
     try test__floatsitf(0x12345678, 0x401b2345678000000000000000000000);
     try test__floatsitf(-0x12345678, 0xc01b2345678000000000000000000000);
-    try test__floatsitf(@as(i32, @bitCast(@as(u32, @intCast(0xffffffff)))), 0xbfff0000000000000000000000000000);
-    try test__floatsitf(@as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), 0xc01e0000000000000000000000000000);
+    try test__floatsitf(@bitCast(@as(u32, @intCast(0xffffffff))), 0xbfff0000000000000000000000000000);
+    try test__floatsitf(@bitCast(@as(u32, @intCast(0x80000000))), 0xc01e0000000000000000000000000000);
 }
 
 fn test__floatunsitf(a: u32, expected_hi: u64, expected_lo: u64) !void {
@@ -575,10 +575,10 @@ test "floatditf" {
     try test__floatditf(0x2, make_tf(0x4000000000000000, 0x0));
     try test__floatditf(0x1, make_tf(0x3fff000000000000, 0x0));
     try test__floatditf(0x0, make_tf(0x0, 0x0));
-    try test__floatditf(@as(i64, @bitCast(@as(u64, 0xffffffffffffffff))), make_tf(0xbfff000000000000, 0x0));
-    try test__floatditf(@as(i64, @bitCast(@as(u64, 0xfffffffffffffffe))), make_tf(0xc000000000000000, 0x0));
+    try test__floatditf(@bitCast(@as(u64, 0xffffffffffffffff)), make_tf(0xbfff000000000000, 0x0));
+    try test__floatditf(@bitCast(@as(u64, 0xfffffffffffffffe)), make_tf(0xc000000000000000, 0x0));
     try test__floatditf(-0x123456789abcdef1, make_tf(0xc03b23456789abcd, 0xef10000000000000));
-    try test__floatditf(@as(i64, @bitCast(@as(u64, 0x8000000000000000))), make_tf(0xc03e000000000000, 0x0));
+    try test__floatditf(@bitCast(@as(u64, 0x8000000000000000)), make_tf(0xc03e000000000000, 0x0));
 }
 
 test "floatunditf" {
@@ -773,7 +773,7 @@ fn make_ti(high: u64, low: u64) i128 {
     var result: u128 = high;
     result <<= 64;
     result |= low;
-    return @as(i128, @bitCast(result));
+    return @bitCast(result);
 }
 
 fn make_uti(high: u64, low: u64) u128 {
@@ -787,7 +787,7 @@ fn make_tf(high: u64, low: u64) f128 {
     var result: u128 = high;
     result <<= 64;
     result |= low;
-    return @as(f128, @bitCast(result));
+    return @bitCast(result);
 }
 
 test "conversion to f16" {
lib/compiler_rt/floor.zig
@@ -40,7 +40,7 @@ pub fn __floorh(x: f16) callconv(.C) f16 {
     }
 
     if (e >= 0) {
-        m = @as(u16, 1023) >> @as(u4, @intCast(e));
+        m = @as(u16, 1023) >> @intCast(e);
         if (u & m == 0) {
             return x;
         }
@@ -48,7 +48,7 @@ pub fn __floorh(x: f16) callconv(.C) f16 {
         if (u >> 15 != 0) {
             u += m;
         }
-        return @as(f16, @bitCast(u & ~m));
+        return @bitCast(u & ~m);
     } else {
         math.doNotOptimizeAway(x + 0x1.0p120);
         if (u >> 15 == 0) {
@@ -60,7 +60,7 @@ pub fn __floorh(x: f16) callconv(.C) f16 {
 }
 
 pub fn floorf(x: f32) callconv(.C) f32 {
-    var u = @as(u32, @bitCast(x));
+    var u: u32 = @bitCast(x);
     const e = @as(i32, @intCast((u >> 23) & 0xFF)) - 0x7F;
     var m: u32 = undefined;
 
@@ -74,7 +74,7 @@ pub fn floorf(x: f32) callconv(.C) f32 {
     }
 
     if (e >= 0) {
-        m = @as(u32, 0x007FFFFF) >> @as(u5, @intCast(e));
+        m = @as(u32, 0x007FFFFF) >> @intCast(e);
         if (u & m == 0) {
             return x;
         }
@@ -82,7 +82,7 @@ pub fn floorf(x: f32) callconv(.C) f32 {
         if (u >> 31 != 0) {
             u += m;
         }
-        return @as(f32, @bitCast(u & ~m));
+        return @bitCast(u & ~m);
     } else {
         math.doNotOptimizeAway(x + 0x1.0p120);
         if (u >> 31 == 0) {
@@ -96,7 +96,7 @@ pub fn floorf(x: f32) callconv(.C) f32 {
 pub fn floor(x: f64) callconv(.C) f64 {
     const f64_toint = 1.0 / math.floatEps(f64);
 
-    const u = @as(u64, @bitCast(x));
+    const u: u64 = @bitCast(x);
     const e = (u >> 52) & 0x7FF;
     var y: f64 = undefined;
 
@@ -126,7 +126,7 @@ pub fn floor(x: f64) callconv(.C) f64 {
 
 pub fn __floorx(x: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(floorq(x)));
+    return @floatCast(floorq(x));
 }
 
 pub fn floorq(x: f128) callconv(.C) f128 {
lib/compiler_rt/fma.zig
@@ -28,7 +28,7 @@ comptime {
 
 pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(fmaf(x, y, z)));
+    return @floatCast(fmaf(x, y, z));
 }
 
 pub fn fmaf(x: f32, y: f32, z: f32) callconv(.C) f32 {
@@ -38,10 +38,10 @@ pub fn fmaf(x: f32, y: f32, z: f32) callconv(.C) f32 {
     const e = (u >> 52) & 0x7FF;
 
     if ((u & 0x1FFFFFFF) != 0x10000000 or e == 0x7FF or (xy_z - xy == z and xy_z - z == xy)) {
-        return @as(f32, @floatCast(xy_z));
+        return @floatCast(xy_z);
     } else {
         // TODO: Handle inexact case with double-rounding
-        return @as(f32, @floatCast(xy_z));
+        return @floatCast(xy_z);
     }
 }
 
@@ -95,7 +95,7 @@ pub fn fma(x: f64, y: f64, z: f64) callconv(.C) f64 {
 
 pub fn __fmax(a: f80, b: f80, c: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(fmaq(a, b, c)));
+    return @floatCast(fmaq(a, b, c));
 }
 
 /// Fused multiply-add: Compute x * y + z with a single rounding error.
@@ -201,12 +201,12 @@ fn dd_mul(a: f64, b: f64) dd {
 fn add_adjusted(a: f64, b: f64) f64 {
     var sum = dd_add(a, b);
     if (sum.lo != 0) {
-        var uhii = @as(u64, @bitCast(sum.hi));
+        var uhii: u64 = @bitCast(sum.hi);
         if (uhii & 1 == 0) {
             // hibits += copysign(1.0, sum.hi, sum.lo)
-            const uloi = @as(u64, @bitCast(sum.lo));
+            const uloi: u64 = @bitCast(sum.lo);
             uhii += 1 - ((uhii ^ uloi) >> 62);
-            sum.hi = @as(f64, @bitCast(uhii));
+            sum.hi = @bitCast(uhii);
         }
     }
     return sum.hi;
@@ -215,12 +215,12 @@ fn add_adjusted(a: f64, b: f64) f64 {
 fn add_and_denorm(a: f64, b: f64, scale: i32) f64 {
     var sum = dd_add(a, b);
     if (sum.lo != 0) {
-        var uhii = @as(u64, @bitCast(sum.hi));
+        var uhii: u64 = @bitCast(sum.hi);
         const bits_lost = -@as(i32, @intCast((uhii >> 52) & 0x7FF)) - scale + 1;
         if ((bits_lost != 1) == (uhii & 1 != 0)) {
-            const uloi = @as(u64, @bitCast(sum.lo));
+            const uloi: u64 = @bitCast(sum.lo);
             uhii += 1 - (((uhii ^ uloi) >> 62) & 2);
-            sum.hi = @as(f64, @bitCast(uhii));
+            sum.hi = @bitCast(uhii);
         }
     }
     return math.scalbn(sum.hi, scale);
@@ -257,12 +257,12 @@ fn dd_add128(a: f128, b: f128) dd128 {
 fn add_adjusted128(a: f128, b: f128) f128 {
     var sum = dd_add128(a, b);
     if (sum.lo != 0) {
-        var uhii = @as(u128, @bitCast(sum.hi));
+        var uhii: u128 = @bitCast(sum.hi);
         if (uhii & 1 == 0) {
             // hibits += copysign(1.0, sum.hi, sum.lo)
-            const uloi = @as(u128, @bitCast(sum.lo));
+            const uloi: u128 = @bitCast(sum.lo);
             uhii += 1 - ((uhii ^ uloi) >> 126);
-            sum.hi = @as(f128, @bitCast(uhii));
+            sum.hi = @bitCast(uhii);
         }
     }
     return sum.hi;
@@ -282,12 +282,12 @@ fn add_and_denorm128(a: f128, b: f128, scale: i32) f128 {
     // If we are losing only one bit to denormalization, however, we must
     // break the ties manually.
     if (sum.lo != 0) {
-        var uhii = @as(u128, @bitCast(sum.hi));
+        var uhii: u128 = @bitCast(sum.hi);
         const bits_lost = -@as(i32, @intCast((uhii >> 112) & 0x7FFF)) - scale + 1;
         if ((bits_lost != 1) == (uhii & 1 != 0)) {
-            const uloi = @as(u128, @bitCast(sum.lo));
+            const uloi: u128 = @bitCast(sum.lo);
             uhii += 1 - (((uhii ^ uloi) >> 126) & 2);
-            sum.hi = @as(f128, @bitCast(uhii));
+            sum.hi = @bitCast(uhii);
         }
     }
     return math.scalbn(sum.hi, scale);
lib/compiler_rt/fmod.zig
@@ -82,8 +82,8 @@ pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 {
 
     var highA: u64 = 0;
     var highB: u64 = 0;
-    var lowA: u64 = @as(u64, @truncate(aRep));
-    var lowB: u64 = @as(u64, @truncate(bRep));
+    var lowA: u64 = @truncate(aRep);
+    var lowB: u64 = @truncate(bRep);
 
     while (expA > expB) : (expA -= 1) {
         var high = highA -% highB;
@@ -125,7 +125,7 @@ pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 {
     if (expA < -fractionalBits) {
         return @bitCast(signA);
     } else if (expA <= 0) {
-        return @bitCast((lowA >> @as(math.Log2Int(u64), @intCast(1 - expA))) | signA);
+        return @bitCast((lowA >> @intCast(1 - expA)) | signA);
     } else {
         return @bitCast(lowA | (@as(Z, @as(u16, @intCast(expA))) << significandBits) | signA);
     }
@@ -136,10 +136,10 @@ pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 {
 pub fn fmodq(a: f128, b: f128) callconv(.C) f128 {
     var amod = a;
     var bmod = b;
-    const aPtr_u64 = @as([*]u64, @ptrCast(&amod));
-    const bPtr_u64 = @as([*]u64, @ptrCast(&bmod));
-    const aPtr_u16 = @as([*]u16, @ptrCast(&amod));
-    const bPtr_u16 = @as([*]u16, @ptrCast(&bmod));
+    const aPtr_u64: [*]u64 = @ptrCast(&amod);
+    const bPtr_u64: [*]u64 = @ptrCast(&bmod);
+    const aPtr_u16: [*]u16 = @ptrCast(&amod);
+    const bPtr_u16: [*]u16 = @ptrCast(&bmod);
 
     const exp_and_sign_index = comptime switch (builtin.target.cpu.arch.endian()) {
         .Little => 7,
@@ -173,8 +173,8 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 {
     }
 
     // Remove the sign from both
-    aPtr_u16[exp_and_sign_index] = @as(u16, @bitCast(@as(i16, @intCast(expA))));
-    bPtr_u16[exp_and_sign_index] = @as(u16, @bitCast(@as(i16, @intCast(expB))));
+    aPtr_u16[exp_and_sign_index] = @bitCast(@as(i16, @intCast(expA)));
+    bPtr_u16[exp_and_sign_index] = @bitCast(@as(i16, @intCast(expB)));
     if (amod <= bmod) {
         if (amod == bmod) {
             return 0 * a;
@@ -264,7 +264,6 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble {
 inline fn generic_fmod(comptime T: type, x: T, y: T) T {
     const bits = @typeInfo(T).Float.bits;
     const uint = std.meta.Int(.unsigned, bits);
-    const log2uint = math.Log2Int(uint);
     comptime assert(T == f32 or T == f64);
     const digits = if (T == f32) 23 else 52;
     const exp_bits = if (T == f32) 9 else 12;
@@ -293,7 +292,7 @@ inline fn generic_fmod(comptime T: type, x: T, y: T) T {
             ex -= 1;
             i <<= 1;
         }) {}
-        ux <<= @as(log2uint, @intCast(@as(u32, @bitCast(-ex + 1))));
+        ux <<= @intCast(@as(u32, @bitCast(-ex + 1)));
     } else {
         ux &= math.maxInt(uint) >> exp_bits;
         ux |= 1 << digits;
@@ -304,7 +303,7 @@ inline fn generic_fmod(comptime T: type, x: T, y: T) T {
             ey -= 1;
             i <<= 1;
         }) {}
-        uy <<= @as(log2uint, @intCast(@as(u32, @bitCast(-ey + 1))));
+        uy <<= @intCast(@as(u32, @bitCast(-ey + 1)));
     } else {
         uy &= math.maxInt(uint) >> exp_bits;
         uy |= 1 << digits;
@@ -336,7 +335,7 @@ inline fn generic_fmod(comptime T: type, x: T, y: T) T {
         ux -%= 1 << digits;
         ux |= @as(uint, @as(u32, @bitCast(ex))) << digits;
     } else {
-        ux >>= @as(log2uint, @intCast(@as(u32, @bitCast(-ex + 1))));
+        ux >>= @intCast(@as(u32, @bitCast(-ex + 1)));
     }
     if (T == f32) {
         ux |= sx;
lib/compiler_rt/int.zig
@@ -52,8 +52,8 @@ test "test_divmodti4" {
         [_]i128{ -7, 5, -1, -2 },
         [_]i128{ 19, 5, 3, 4 },
         [_]i128{ 19, -5, -3, 4 },
-        [_]i128{ @as(i128, @bitCast(@as(u128, 0x80000000000000000000000000000000))), 8, @as(i128, @bitCast(@as(u128, 0xf0000000000000000000000000000000))), 0 },
-        [_]i128{ @as(i128, @bitCast(@as(u128, 0x80000000000000000000000000000007))), 8, @as(i128, @bitCast(@as(u128, 0xf0000000000000000000000000000001))), -1 },
+        [_]i128{ @bitCast(@as(u128, 0x80000000000000000000000000000000)), 8, @bitCast(@as(u128, 0xf0000000000000000000000000000000)), 0 },
+        [_]i128{ @bitCast(@as(u128, 0x80000000000000000000000000000007)), 8, @bitCast(@as(u128, 0xf0000000000000000000000000000001)), -1 },
     };
 
     for (cases) |case| {
@@ -85,8 +85,8 @@ test "test_divmoddi4" {
         [_]i64{ -7, 5, -1, -2 },
         [_]i64{ 19, 5, 3, 4 },
         [_]i64{ 19, -5, -3, 4 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), 8, @bitCast(@as(u64, 0xf000000000000000)), 0 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000007)), 8, @bitCast(@as(u64, 0xf000000000000001)), -1 },
     };
 
     for (cases) |case| {
@@ -110,14 +110,14 @@ test "test_udivmoddi4" {
 
 pub fn __divdi3(a: i64, b: i64) callconv(.C) i64 {
     // Set aside the sign of the quotient.
-    const sign = @as(u64, @bitCast((a ^ b) >> 63));
+    const sign: u64 = @bitCast((a ^ b) >> 63);
     // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63).
     const abs_a = (a ^ (a >> 63)) -% (a >> 63);
     const abs_b = (b ^ (b >> 63)) -% (b >> 63);
     // Unsigned division
-    const res = __udivmoddi4(@as(u64, @bitCast(abs_a)), @as(u64, @bitCast(abs_b)), null);
+    const res = __udivmoddi4(@bitCast(abs_a), @bitCast(abs_b), null);
     // Apply sign of quotient to result and return.
-    return @as(i64, @bitCast((res ^ sign) -% sign));
+    return @bitCast((res ^ sign) -% sign);
 }
 
 test "test_divdi3" {
@@ -151,7 +151,7 @@ pub fn __moddi3(a: i64, b: i64) callconv(.C) i64 {
     const abs_b = (b ^ (b >> 63)) -% (b >> 63);
     // Unsigned division
     var r: u64 = undefined;
-    _ = __udivmoddi4(@as(u64, @bitCast(abs_a)), @as(u64, @bitCast(abs_b)), &r);
+    _ = __udivmoddi4(@bitCast(abs_a), @bitCast(abs_b), &r);
     // Apply the sign of the dividend and return.
     return (@as(i64, @bitCast(r)) ^ (a >> 63)) -% (a >> 63);
 }
@@ -165,12 +165,12 @@ test "test_moddi3" {
         [_]i64{ -5, 3, -2 },
         [_]i64{ -5, -3, -2 },
 
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 1, 0 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), -1, 0 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 2, 0 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), -2, 0 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 3, -2 },
-        [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), -3, -2 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), 1, 0 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), -1, 0 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), 2, 0 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), -2, 0 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), 3, -2 },
+        [_]i64{ @bitCast(@as(u64, 0x8000000000000000)), -3, -2 },
     };
 
     for (cases) |case| {
@@ -225,8 +225,8 @@ test "test_divmodsi4" {
         [_]i32{ 19, 5, 3, 4 },
         [_]i32{ 19, -5, -3, 4 },
 
-        [_]i32{ @as(i32, @bitCast(@as(u32, 0x80000000))), 8, @as(i32, @bitCast(@as(u32, 0xf0000000))), 0 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, 0x80000007))), 8, @as(i32, @bitCast(@as(u32, 0xf0000001))), -1 },
+        [_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
+        [_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
     };
 
     for (cases) |case| {
@@ -242,7 +242,7 @@ fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
 
 pub fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 {
     const d = __udivsi3(a, b);
-    rem.* = @as(u32, @bitCast(@as(i32, @bitCast(a)) -% (@as(i32, @bitCast(d)) * @as(i32, @bitCast(b)))));
+    rem.* = @bitCast(@as(i32, @bitCast(a)) -% (@as(i32, @bitCast(d)) * @as(i32, @bitCast(b))));
     return d;
 }
 
@@ -256,14 +256,14 @@ fn __aeabi_idiv(n: i32, d: i32) callconv(.AAPCS) i32 {
 
 inline fn div_i32(n: i32, d: i32) i32 {
     // Set aside the sign of the quotient.
-    const sign = @as(u32, @bitCast((n ^ d) >> 31));
+    const sign: u32 = @bitCast((n ^ d) >> 31);
     // Take absolute value of a and b via abs(x) = (x^(x >> 31)) - (x >> 31).
     const abs_n = (n ^ (n >> 31)) -% (n >> 31);
     const abs_d = (d ^ (d >> 31)) -% (d >> 31);
     // abs(a) / abs(b)
     const res = @as(u32, @bitCast(abs_n)) / @as(u32, @bitCast(abs_d));
     // Apply sign of quotient to result and return.
-    return @as(i32, @bitCast((res ^ sign) -% sign));
+    return @bitCast((res ^ sign) -% sign);
 }
 
 test "test_divsi3" {
@@ -275,10 +275,10 @@ test "test_divsi3" {
         [_]i32{ -2, 1, -2 },
         [_]i32{ -2, -1, 2 },
 
-        [_]i32{ @as(i32, @bitCast(@as(u32, 0x80000000))), 1, @as(i32, @bitCast(@as(u32, 0x80000000))) },
-        [_]i32{ @as(i32, @bitCast(@as(u32, 0x80000000))), -1, @as(i32, @bitCast(@as(u32, 0x80000000))) },
-        [_]i32{ @as(i32, @bitCast(@as(u32, 0x80000000))), -2, 0x40000000 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, 0x80000000))), 2, @as(i32, @bitCast(@as(u32, 0xC0000000))) },
+        [_]i32{ @bitCast(@as(u32, 0x80000000)), 1, @bitCast(@as(u32, 0x80000000)) },
+        [_]i32{ @bitCast(@as(u32, 0x80000000)), -1, @bitCast(@as(u32, 0x80000000)) },
+        [_]i32{ @bitCast(@as(u32, 0x80000000)), -2, 0x40000000 },
+        [_]i32{ @bitCast(@as(u32, 0x80000000)), 2, @bitCast(@as(u32, 0xC0000000)) },
     };
 
     for (cases) |case| {
@@ -317,12 +317,12 @@ inline fn div_u32(n: u32, d: u32) u32 {
     sr += 1;
     // 1 <= sr <= n_uword_bits - 1
     // Not a special case
-    var q: u32 = n << @as(u5, @intCast(n_uword_bits - sr));
-    var r: u32 = n >> @as(u5, @intCast(sr));
+    var q: u32 = n << @intCast(n_uword_bits - sr);
+    var r: u32 = n >> @intCast(sr);
     var carry: u32 = 0;
     while (sr > 0) : (sr -= 1) {
         // r:q = ((r:q)  << 1) | carry
-        r = (r << 1) | (q >> @as(u5, @intCast(n_uword_bits - 1)));
+        r = (r << 1) | (q >> @intCast(n_uword_bits - 1));
         q = (q << 1) | carry;
         // carry = 0;
         // if (r.all >= d.all)
@@ -330,8 +330,8 @@ inline fn div_u32(n: u32, d: u32) u32 {
         //      r.all -= d.all;
         //      carry = 1;
         // }
-        const s = @as(i32, @bitCast(d -% r -% 1)) >> @as(u5, @intCast(n_uword_bits - 1));
-        carry = @as(u32, @intCast(s & 1));
+        const s = @as(i32, @bitCast(d -% r -% 1)) >> @intCast(n_uword_bits - 1);
+        carry = @intCast(s & 1);
         r -= d & @as(u32, @bitCast(s));
     }
     q = (q << 1) | carry;
@@ -496,11 +496,11 @@ test "test_modsi3" {
         [_]i32{ 5, -3, 2 },
         [_]i32{ -5, 3, -2 },
         [_]i32{ -5, -3, -2 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), 1, 0x0 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), 2, 0x0 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), -2, 0x0 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), 3, -2 },
-        [_]i32{ @as(i32, @bitCast(@as(u32, @intCast(0x80000000)))), -3, -2 },
+        [_]i32{ @bitCast(@as(u32, @intCast(0x80000000))), 1, 0x0 },
+        [_]i32{ @bitCast(@as(u32, @intCast(0x80000000))), 2, 0x0 },
+        [_]i32{ @bitCast(@as(u32, @intCast(0x80000000))), -2, 0x0 },
+        [_]i32{ @bitCast(@as(u32, @intCast(0x80000000))), 3, -2 },
+        [_]i32{ @bitCast(@as(u32, @intCast(0x80000000))), -3, -2 },
     };
 
     for (cases) |case| {
lib/compiler_rt/int_from_float.zig
@@ -17,7 +17,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I {
     const sig_mask = (@as(rep_t, 1) << sig_bits) - 1;
 
     // Break a into sign, exponent, significand
-    const a_rep: rep_t = @as(rep_t, @bitCast(a));
+    const a_rep: rep_t = @bitCast(a);
     const negative = (a_rep >> (float_bits - 1)) != 0;
     const exponent = @as(i32, @intCast((a_rep << 1) >> (sig_bits + 1))) - exp_bias;
     const significand: rep_t = (a_rep & sig_mask) | implicit_bit;
@@ -40,9 +40,9 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I {
     // Otherwise, shift left.
     var result: I = undefined;
     if (exponent < fractional_bits) {
-        result = @as(I, @intCast(significand >> @as(Log2Int(rep_t), @intCast(fractional_bits - exponent))));
+        result = @intCast(significand >> @intCast(fractional_bits - exponent));
     } else {
-        result = @as(I, @intCast(significand)) << @as(Log2Int(I), @intCast(exponent - fractional_bits));
+        result = @as(I, @intCast(significand)) << @intCast(exponent - fractional_bits);
     }
 
     if ((@typeInfo(I).Int.signedness == .signed) and negative)
lib/compiler_rt/log10.zig
@@ -28,7 +28,7 @@ comptime {
 
 pub fn __log10h(a: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(log10f(a)));
+    return @floatCast(log10f(a));
 }
 
 pub fn log10f(x_: f32) callconv(.C) f32 {
@@ -42,7 +42,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 {
     const Lg4: f32 = 0xf89e26.0p-26;
 
     var x = x_;
-    var u = @as(u32, @bitCast(x));
+    var u: u32 = @bitCast(x);
     var ix = u;
     var k: i32 = 0;
 
@@ -59,7 +59,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 {
 
         k -= 25;
         x *= 0x1.0p25;
-        ix = @as(u32, @bitCast(x));
+        ix = @bitCast(x);
     } else if (ix >= 0x7F800000) {
         return x;
     } else if (ix == 0x3F800000) {
@@ -70,7 +70,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 {
     ix += 0x3F800000 - 0x3F3504F3;
     k += @as(i32, @intCast(ix >> 23)) - 0x7F;
     ix = (ix & 0x007FFFFF) + 0x3F3504F3;
-    x = @as(f32, @bitCast(ix));
+    x = @bitCast(ix);
 
     const f = x - 1.0;
     const s = f / (2.0 + f);
@@ -168,12 +168,12 @@ pub fn log10(x_: f64) callconv(.C) f64 {
 
 pub fn __log10x(a: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(log10q(a)));
+    return @floatCast(log10q(a));
 }
 
 pub fn log10q(a: f128) callconv(.C) f128 {
     // TODO: more correct implementation
-    return log10(@as(f64, @floatCast(a)));
+    return log10(@floatCast(a));
 }
 
 pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble {
lib/compiler_rt/modti3_test.zig
@@ -33,5 +33,5 @@ fn make_ti(high: u64, low: u64) i128 {
     var result: u128 = high;
     result <<= 64;
     result |= low;
-    return @as(i128, @bitCast(result));
+    return @bitCast(result);
 }
lib/compiler_rt/mulf3.zig
@@ -29,16 +29,16 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
 
     const absMask = signBit - 1;
     const qnanRep = @as(Z, @bitCast(math.nan(T))) | quietBit;
-    const infRep = @as(Z, @bitCast(math.inf(T)));
-    const minNormalRep = @as(Z, @bitCast(math.floatMin(T)));
+    const infRep: Z = @bitCast(math.inf(T));
+    const minNormalRep: Z = @bitCast(math.floatMin(T));
 
     const ZExp = if (typeWidth >= 32) u32 else Z;
-    const aExponent = @as(ZExp, @truncate((@as(Z, @bitCast(a)) >> significandBits) & maxExponent));
-    const bExponent = @as(ZExp, @truncate((@as(Z, @bitCast(b)) >> significandBits) & maxExponent));
+    const aExponent: ZExp = @truncate((@as(Z, @bitCast(a)) >> significandBits) & maxExponent);
+    const bExponent: ZExp = @truncate((@as(Z, @bitCast(b)) >> significandBits) & maxExponent);
     const productSign: Z = (@as(Z, @bitCast(a)) ^ @as(Z, @bitCast(b))) & signBit;
 
-    var aSignificand: ZSignificand = @as(ZSignificand, @intCast(@as(Z, @bitCast(a)) & significandMask));
-    var bSignificand: ZSignificand = @as(ZSignificand, @intCast(@as(Z, @bitCast(b)) & significandMask));
+    var aSignificand: ZSignificand = @intCast(@as(Z, @bitCast(a)) & significandMask);
+    var bSignificand: ZSignificand = @intCast(@as(Z, @bitCast(b)) & significandMask);
     var scale: i32 = 0;
 
     // Detect if a or b is zero, denormal, infinity, or NaN.
@@ -47,9 +47,9 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
         const bAbs: Z = @as(Z, @bitCast(b)) & absMask;
 
         // NaN * anything = qNaN
-        if (aAbs > infRep) return @as(T, @bitCast(@as(Z, @bitCast(a)) | quietBit));
+        if (aAbs > infRep) return @bitCast(@as(Z, @bitCast(a)) | quietBit);
         // anything * NaN = qNaN
-        if (bAbs > infRep) return @as(T, @bitCast(@as(Z, @bitCast(b)) | quietBit));
+        if (bAbs > infRep) return @bitCast(@as(Z, @bitCast(b)) | quietBit);
 
         if (aAbs == infRep) {
             // infinity * non-zero = +/- infinity
@@ -110,7 +110,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
     }
 
     // If we have overflowed the type, return +/- infinity.
-    if (productExponent >= maxExponent) return @as(T, @bitCast(infRep | productSign));
+    if (productExponent >= maxExponent) return @bitCast(infRep | productSign);
 
     var result: Z = undefined;
     if (productExponent <= 0) {
@@ -120,8 +120,8 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
         // a zero of the appropriate sign.  Mathematically there is no need to
         // handle this case separately, but we make it a special case to
         // simplify the shift logic.
-        const shift: u32 = @as(u32, @truncate(@as(Z, 1) -% @as(u32, @bitCast(productExponent))));
-        if (shift >= ZSignificandBits) return @as(T, @bitCast(productSign));
+        const shift: u32 = @truncate(@as(Z, 1) -% @as(u32, @bitCast(productExponent)));
+        if (shift >= ZSignificandBits) return @bitCast(productSign);
 
         // Otherwise, shift the significand of the result so that the round
         // bit is the high bit of productLo.
@@ -156,7 +156,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
     // Insert the sign of the result:
     result |= productSign;
 
-    return @as(T, @bitCast(result));
+    return @bitCast(result);
 }
 
 /// Returns `true` if the right shift is inexact (i.e. any bit shifted out is non-zero)
@@ -165,15 +165,14 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
 fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {
     @setRuntimeSafety(builtin.is_test);
     const typeWidth = @typeInfo(Z).Int.bits;
-    const S = math.Log2Int(Z);
     var inexact = false;
     if (count < typeWidth) {
-        inexact = (lo.* << @as(S, @intCast(typeWidth -% count))) != 0;
-        lo.* = (hi.* << @as(S, @intCast(typeWidth -% count))) | (lo.* >> @as(S, @intCast(count)));
-        hi.* = hi.* >> @as(S, @intCast(count));
+        inexact = (lo.* << @intCast(typeWidth -% count)) != 0;
+        lo.* = (hi.* << @intCast(typeWidth -% count)) | (lo.* >> @intCast(count));
+        hi.* = hi.* >> @intCast(count);
     } else if (count < 2 * typeWidth) {
-        inexact = (hi.* << @as(S, @intCast(2 * typeWidth -% count)) | lo.*) != 0;
-        lo.* = hi.* >> @as(S, @intCast(count -% typeWidth));
+        inexact = (hi.* << @intCast(2 * typeWidth -% count) | lo.*) != 0;
+        lo.* = hi.* >> @intCast(count -% typeWidth);
         hi.* = 0;
     } else {
         inexact = (hi.* | lo.*) != 0;
@@ -188,7 +187,7 @@ fn normalize(comptime T: type, significand: *PowerOfTwoSignificandZ(T)) i32 {
     const integerBit = @as(Z, 1) << math.floatFractionalBits(T);
 
     const shift = @clz(significand.*) - @clz(integerBit);
-    significand.* <<= @as(math.Log2Int(Z), @intCast(shift));
+    significand.* <<= @intCast(shift);
     return @as(i32, 1) - shift;
 }
 
lib/compiler_rt/parity.zig
@@ -26,12 +26,7 @@ pub fn __parityti2(a: i128) callconv(.C) i32 {
 }
 
 inline fn parityXi2(comptime T: type, a: T) i32 {
-    var x = switch (@bitSizeOf(T)) {
-        32 => @as(u32, @bitCast(a)),
-        64 => @as(u64, @bitCast(a)),
-        128 => @as(u128, @bitCast(a)),
-        else => unreachable,
-    };
+    var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a);
     // Bit Twiddling Hacks: Compute parity in parallel
     comptime var shift: u8 = @bitSizeOf(T) / 2;
     inline while (shift > 2) {
@@ -39,7 +34,7 @@ inline fn parityXi2(comptime T: type, a: T) i32 {
         shift = shift >> 1;
     }
     x &= 0xf;
-    return (@as(u16, @intCast(0x6996)) >> @as(u4, @intCast(x))) & 1; // optimization for >>2 and >>1
+    return (@as(u16, 0x6996) >> @intCast(x)) & 1; // optimization for >>2 and >>1
 }
 
 test {
lib/compiler_rt/paritydi2_test.zig
@@ -3,13 +3,13 @@ const parity = @import("parity.zig");
 const testing = std.testing;
 
 fn paritydi2Naive(a: i64) i32 {
-    var x = @as(u64, @bitCast(a));
+    var x: u64 = @bitCast(a);
     var has_parity: bool = false;
     while (x > 0) {
         has_parity = !has_parity;
         x = x & (x - 1);
     }
-    return @as(i32, @intCast(@intFromBool(has_parity)));
+    return @intCast(@intFromBool(has_parity));
 }
 
 fn test__paritydi2(a: i64) !void {
@@ -22,9 +22,9 @@ test "paritydi2" {
     try test__paritydi2(0);
     try test__paritydi2(1);
     try test__paritydi2(2);
-    try test__paritydi2(@as(i64, @bitCast(@as(u64, 0xffffffff_fffffffd))));
-    try test__paritydi2(@as(i64, @bitCast(@as(u64, 0xffffffff_fffffffe))));
-    try test__paritydi2(@as(i64, @bitCast(@as(u64, 0xffffffff_ffffffff))));
+    try test__paritydi2(@bitCast(@as(u64, 0xffffffff_fffffffd)));
+    try test__paritydi2(@bitCast(@as(u64, 0xffffffff_fffffffe)));
+    try test__paritydi2(@bitCast(@as(u64, 0xffffffff_ffffffff)));
 
     const RndGen = std.rand.DefaultPrng;
     var rnd = RndGen.init(42);
lib/compiler_rt/paritysi2_test.zig
@@ -3,13 +3,13 @@ const parity = @import("parity.zig");
 const testing = std.testing;
 
 fn paritysi2Naive(a: i32) i32 {
-    var x = @as(u32, @bitCast(a));
+    var x: u32 = @bitCast(a);
     var has_parity: bool = false;
     while (x > 0) {
         has_parity = !has_parity;
         x = x & (x - 1);
     }
-    return @as(i32, @intCast(@intFromBool(has_parity)));
+    return @intCast(@intFromBool(has_parity));
 }
 
 fn test__paritysi2(a: i32) !void {
@@ -22,9 +22,9 @@ test "paritysi2" {
     try test__paritysi2(0);
     try test__paritysi2(1);
     try test__paritysi2(2);
-    try test__paritysi2(@as(i32, @bitCast(@as(u32, 0xfffffffd))));
-    try test__paritysi2(@as(i32, @bitCast(@as(u32, 0xfffffffe))));
-    try test__paritysi2(@as(i32, @bitCast(@as(u32, 0xffffffff))));
+    try test__paritysi2(@bitCast(@as(u32, 0xfffffffd)));
+    try test__paritysi2(@bitCast(@as(u32, 0xfffffffe)));
+    try test__paritysi2(@bitCast(@as(u32, 0xffffffff)));
 
     const RndGen = std.rand.DefaultPrng;
     var rnd = RndGen.init(42);
lib/compiler_rt/parityti2_test.zig
@@ -9,7 +9,7 @@ fn parityti2Naive(a: i128) i32 {
         has_parity = !has_parity;
         x = x & (x - 1);
     }
-    return @as(i32, @intCast(@intFromBool(has_parity)));
+    return @intCast(@intFromBool(has_parity));
 }
 
 fn test__parityti2(a: i128) !void {
@@ -22,9 +22,9 @@ test "parityti2" {
     try test__parityti2(0);
     try test__parityti2(1);
     try test__parityti2(2);
-    try test__parityti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffd))));
-    try test__parityti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))));
-    try test__parityti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))));
+    try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffd)));
+    try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe)));
+    try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff)));
 
     const RndGen = std.rand.DefaultPrng;
     var rnd = RndGen.init(42);
lib/compiler_rt/popcount.zig
@@ -37,7 +37,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
         i128 => u128,
         else => unreachable,
     };
-    var x = @as(UT, @bitCast(a));
+    var x: UT = @bitCast(a);
     x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
     x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
     + (x & (~@as(UT, 0) / 5));
@@ -46,7 +46,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
     // 8 most significant bits of x + (x<<8) + (x<<16) + ..
     x *%= ~@as(UT, 0) / 255; // 0x01...01
     x >>= (@bitSizeOf(ST) - 8);
-    return @as(i32, @intCast(x));
+    return @intCast(x);
 }
 
 test {
lib/compiler_rt/rem_pio2.zig
@@ -25,10 +25,6 @@ const pio2_3 = 2.02226624871116645580e-21; // 0x3BA3198A, 0x2E000000
 // pio2_3t:  pi/2 - (pio2_1+pio2_2+pio2_3)
 const pio2_3t = 8.47842766036889956997e-32; // 0x397B839A, 0x252049C1
 
-fn U(x: anytype) usize {
-    return @as(usize, @intCast(x));
-}
-
 fn medium(ix: u32, x: f64, y: *[2]f64) i32 {
     var w: f64 = undefined;
     var t: f64 = undefined;
@@ -41,7 +37,7 @@ fn medium(ix: u32, x: f64, y: *[2]f64) i32 {
 
     // rint(x/(pi/2))
     @"fn" = x * invpio2 + toint - toint;
-    n = @as(i32, @intFromFloat(@"fn"));
+    n = @intFromFloat(@"fn");
     r = x - @"fn" * pio2_1;
     w = @"fn" * pio2_1t; // 1st round, good to 85 bits
     // Matters with directed rounding.
@@ -174,16 +170,16 @@ pub fn rem_pio2(x: f64, y: *[2]f64) i32 {
     ui = @bitCast(x);
     ui &= std.math.maxInt(u64) >> 12;
     ui |= @as(u64, 0x3ff + 23) << 52;
-    z = @as(f64, @bitCast(ui));
+    z = @bitCast(ui);
 
     i = 0;
     while (i < 2) : (i += 1) {
-        tx[U(i)] = @as(f64, @floatFromInt(@as(i32, @intFromFloat(z))));
-        z = (z - tx[U(i)]) * 0x1p24;
+        tx[@intCast(i)] = @floatFromInt(@as(i32, @intFromFloat(z)));
+        z = (z - tx[@intCast(i)]) * 0x1p24;
     }
-    tx[U(i)] = z;
+    tx[@intCast(i)] = z;
     // skip zero terms, first term is non-zero
-    while (tx[U(i)] == 0.0) {
+    while (tx[@intCast(i)] == 0.0) {
         i -= 1;
     }
     n = rem_pio2_large(tx[0..], ty[0..], @as(i32, @intCast((ix >> 20))) - (0x3ff + 23), i + 1, 1);
lib/compiler_rt/rem_pio2_large.zig
@@ -149,10 +149,6 @@ const PIo2 = [_]f64{
     2.16741683877804819444e-51, // 0x3569F31D, 0x00000000
 };
 
-fn U(x: anytype) usize {
-    return @as(usize, @intCast(x));
-}
-
 /// Returns the last three digits of N with y = x - N*pi/2 so that |y| < pi/2.
 ///
 /// The method is to compute the integer (mod 8) and fraction parts of
@@ -295,7 +291,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
         i += 1;
         j += 1;
     }) {
-        f[U(i)] = if (j < 0) 0.0 else @as(f64, @floatFromInt(ipio2[U(j)]));
+        f[@intCast(i)] = if (j < 0) 0.0 else @floatFromInt(ipio2[@intCast(j)]);
     }
 
     // compute q[0],q[1],...q[jk]
@@ -304,9 +300,9 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
         j = 0;
         fw = 0;
         while (j <= jx) : (j += 1) {
-            fw += x[U(j)] * f[U(jx + i - j)];
+            fw += x[@intCast(j)] * f[@intCast(jx + i - j)];
         }
-        q[U(i)] = fw;
+        q[@intCast(i)] = fw;
     }
 
     jz = jk;
@@ -317,29 +313,29 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
         // distill q[] into iq[] reversingly
         i = 0;
         j = jz;
-        z = q[U(jz)];
+        z = q[@intCast(jz)];
         while (j > 0) : ({
             i += 1;
             j -= 1;
         }) {
             fw = @floatFromInt(@as(i32, @intFromFloat(0x1p-24 * z)));
-            iq[U(i)] = @as(i32, @intFromFloat(z - 0x1p24 * fw));
-            z = q[U(j - 1)] + fw;
+            iq[@intCast(i)] = @intFromFloat(z - 0x1p24 * fw);
+            z = q[@intCast(j - 1)] + fw;
         }
 
         // compute n
         z = math.scalbn(z, q0); // actual value of z
         z -= 8.0 * @floor(z * 0.125); // trim off integer >= 8
         n = @intFromFloat(z);
-        z -= @as(f64, @floatFromInt(n));
+        z -= @floatFromInt(n);
         ih = 0;
         if (q0 > 0) { // need iq[jz-1] to determine n
-            i = iq[U(jz - 1)] >> @as(u5, @intCast(24 - q0));
+            i = iq[@intCast(jz - 1)] >> @intCast(24 - q0);
             n += i;
-            iq[U(jz - 1)] -= i << @as(u5, @intCast(24 - q0));
-            ih = iq[U(jz - 1)] >> @as(u5, @intCast(23 - q0));
+            iq[@intCast(jz - 1)] -= i << @intCast(24 - q0);
+            ih = iq[@intCast(jz - 1)] >> @intCast(23 - q0);
         } else if (q0 == 0) {
-            ih = iq[U(jz - 1)] >> 23;
+            ih = iq[@intCast(jz - 1)] >> 23;
         } else if (z >= 0.5) {
             ih = 2;
         }
@@ -349,20 +345,20 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
             carry = 0;
             i = 0;
             while (i < jz) : (i += 1) { // compute 1-q
-                j = iq[U(i)];
+                j = iq[@intCast(i)];
                 if (carry == 0) {
                     if (j != 0) {
                         carry = 1;
-                        iq[U(i)] = 0x1000000 - j;
+                        iq[@intCast(i)] = 0x1000000 - j;
                     }
                 } else {
-                    iq[U(i)] = 0xffffff - j;
+                    iq[@intCast(i)] = 0xffffff - j;
                 }
             }
             if (q0 > 0) { // rare case: chance is 1 in 12
                 switch (q0) {
-                    1 => iq[U(jz - 1)] &= 0x7fffff,
-                    2 => iq[U(jz - 1)] &= 0x3fffff,
+                    1 => iq[@intCast(jz - 1)] &= 0x7fffff,
+                    2 => iq[@intCast(jz - 1)] &= 0x3fffff,
                     else => unreachable,
                 }
             }
@@ -379,24 +375,24 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
             j = 0;
             i = jz - 1;
             while (i >= jk) : (i -= 1) {
-                j |= iq[U(i)];
+                j |= iq[@intCast(i)];
             }
 
             if (j == 0) { // need recomputation
                 k = 1;
-                while (iq[U(jk - k)] == 0) : (k += 1) {
+                while (iq[@intCast(jk - k)] == 0) : (k += 1) {
                     // k = no. of terms needed
                 }
 
                 i = jz + 1;
                 while (i <= jz + k) : (i += 1) { // add q[jz+1] to q[jz+k]
-                    f[U(jx + i)] = @as(f64, @floatFromInt(ipio2[U(jv + i)]));
+                    f[@intCast(jx + i)] = @floatFromInt(ipio2[@intCast(jv + i)]);
                     j = 0;
                     fw = 0;
                     while (j <= jx) : (j += 1) {
-                        fw += x[U(j)] * f[U(jx + i - j)];
+                        fw += x[@intCast(j)] * f[@intCast(jx + i - j)];
                     }
-                    q[U(i)] = fw;
+                    q[@intCast(i)] = fw;
                 }
                 jz += k;
                 continue :recompute; // mimic goto recompute
@@ -407,7 +403,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
         if (z == 0.0) {
             jz -= 1;
             q0 -= 24;
-            while (iq[U(jz)] == 0) {
+            while (iq[@intCast(jz)] == 0) {
                 jz -= 1;
                 q0 -= 24;
             }
@@ -415,12 +411,12 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
             z = math.scalbn(z, -q0);
             if (z >= 0x1p24) {
                 fw = @floatFromInt(@as(i32, @intFromFloat(0x1p-24 * z)));
-                iq[U(jz)] = @as(i32, @intFromFloat(z - 0x1p24 * fw));
+                iq[@intCast(jz)] = @intFromFloat(z - 0x1p24 * fw);
                 jz += 1;
                 q0 += 24;
-                iq[U(jz)] = @as(i32, @intFromFloat(fw));
+                iq[@intCast(jz)] = @intFromFloat(fw);
             } else {
-                iq[U(jz)] = @as(i32, @intFromFloat(z));
+                iq[@intCast(jz)] = @intFromFloat(z);
             }
         }
 
@@ -428,7 +424,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
         fw = math.scalbn(@as(f64, 1.0), q0);
         i = jz;
         while (i >= 0) : (i -= 1) {
-            q[U(i)] = fw * @as(f64, @floatFromInt(iq[U(i)]));
+            q[@intCast(i)] = fw * @as(f64, @floatFromInt(iq[@intCast(i)]));
             fw *= 0x1p-24;
         }
 
@@ -438,9 +434,9 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
             fw = 0;
             k = 0;
             while (k <= jp and k <= jz - i) : (k += 1) {
-                fw += PIo2[U(k)] * q[U(i + k)];
+                fw += PIo2[@intCast(k)] * q[@intCast(i + k)];
             }
-            fq[U(jz - i)] = fw;
+            fq[@intCast(jz - i)] = fw;
         }
 
         // compress fq[] into y[]
@@ -449,7 +445,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
                 fw = 0.0;
                 i = jz;
                 while (i >= 0) : (i -= 1) {
-                    fw += fq[U(i)];
+                    fw += fq[@intCast(i)];
                 }
                 y[0] = if (ih == 0) fw else -fw;
             },
@@ -458,7 +454,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
                 fw = 0.0;
                 i = jz;
                 while (i >= 0) : (i -= 1) {
-                    fw += fq[U(i)];
+                    fw += fq[@intCast(i)];
                 }
                 // TODO: drop excess precision here once double_t is used
                 fw = fw;
@@ -466,27 +462,27 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
                 fw = fq[0] - fw;
                 i = 1;
                 while (i <= jz) : (i += 1) {
-                    fw += fq[U(i)];
+                    fw += fq[@intCast(i)];
                 }
                 y[1] = if (ih == 0) fw else -fw;
             },
             3 => { // painful
                 i = jz;
                 while (i > 0) : (i -= 1) {
-                    fw = fq[U(i - 1)] + fq[U(i)];
-                    fq[U(i)] += fq[U(i - 1)] - fw;
-                    fq[U(i - 1)] = fw;
+                    fw = fq[@intCast(i - 1)] + fq[@intCast(i)];
+                    fq[@intCast(i)] += fq[@intCast(i - 1)] - fw;
+                    fq[@intCast(i - 1)] = fw;
                 }
                 i = jz;
                 while (i > 1) : (i -= 1) {
-                    fw = fq[U(i - 1)] + fq[U(i)];
-                    fq[U(i)] += fq[U(i - 1)] - fw;
-                    fq[U(i - 1)] = fw;
+                    fw = fq[@intCast(i - 1)] + fq[@intCast(i)];
+                    fq[@intCast(i)] += fq[@intCast(i - 1)] - fw;
+                    fq[@intCast(i - 1)] = fw;
                 }
                 fw = 0;
                 i = jz;
                 while (i >= 2) : (i -= 1) {
-                    fw += fq[U(i)];
+                    fw += fq[@intCast(i)];
                 }
                 if (ih == 0) {
                     y[0] = fq[0];
lib/compiler_rt/shift.zig
@@ -30,20 +30,19 @@ comptime {
 // Precondition: 0 <= b < bits_in_dword
 inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
     const word_t = common.HalveInt(T, false);
-    const S = Log2Int(word_t.HalfT);
 
     const input = word_t{ .all = a };
     var output: word_t = undefined;
 
     if (b >= word_t.bits) {
         output.s.low = 0;
-        output.s.high = input.s.low << @as(S, @intCast(b - word_t.bits));
+        output.s.high = input.s.low << @intCast(b - word_t.bits);
     } else if (b == 0) {
         return a;
     } else {
-        output.s.low = input.s.low << @as(S, @intCast(b));
-        output.s.high = input.s.high << @as(S, @intCast(b));
-        output.s.high |= input.s.low >> @as(S, @intCast(word_t.bits - b));
+        output.s.low = input.s.low << @intCast(b);
+        output.s.high = input.s.high << @intCast(b);
+        output.s.high |= input.s.low >> @intCast(word_t.bits - b);
     }
 
     return output.all;
@@ -53,24 +52,20 @@ inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
 // Precondition: 0 <= b < T.bit_count
 inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
     const word_t = common.HalveInt(T, true);
-    const S = Log2Int(word_t.HalfT);
 
     const input = word_t{ .all = a };
     var output: word_t = undefined;
 
     if (b >= word_t.bits) {
         output.s.high = input.s.high >> (word_t.bits - 1);
-        output.s.low = input.s.high >> @as(S, @intCast(b - word_t.bits));
+        output.s.low = input.s.high >> @intCast(b - word_t.bits);
     } else if (b == 0) {
         return a;
     } else {
-        output.s.high = input.s.high >> @as(S, @intCast(b));
-        output.s.low = input.s.high << @as(S, @intCast(word_t.bits - b));
+        output.s.high = input.s.high >> @intCast(b);
+        output.s.low = input.s.high << @intCast(word_t.bits - b);
         // Avoid sign-extension here
-        output.s.low |= @as(
-            word_t.HalfT,
-            @bitCast(@as(word_t.HalfTU, @bitCast(input.s.low)) >> @as(S, @intCast(b))),
-        );
+        output.s.low |= @bitCast(@as(word_t.HalfTU, @bitCast(input.s.low)) >> @intCast(b));
     }
 
     return output.all;
@@ -80,20 +75,19 @@ inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
 // Precondition: 0 <= b < T.bit_count
 inline fn lshrXi3(comptime T: type, a: T, b: i32) T {
     const word_t = common.HalveInt(T, false);
-    const S = Log2Int(word_t.HalfT);
 
     const input = word_t{ .all = a };
     var output: word_t = undefined;
 
     if (b >= word_t.bits) {
         output.s.high = 0;
-        output.s.low = input.s.high >> @as(S, @intCast(b - word_t.bits));
+        output.s.low = input.s.high >> @intCast(b - word_t.bits);
     } else if (b == 0) {
         return a;
     } else {
-        output.s.high = input.s.high >> @as(S, @intCast(b));
-        output.s.low = input.s.high << @as(S, @intCast(word_t.bits - b));
-        output.s.low |= input.s.low >> @as(S, @intCast(b));
+        output.s.high = input.s.high >> @intCast(b);
+        output.s.low = input.s.high << @intCast(word_t.bits - b);
+        output.s.low |= input.s.low >> @intCast(b);
     }
 
     return output.all;
lib/compiler_rt/sin.zig
@@ -31,7 +31,7 @@ comptime {
 
 pub fn __sinh(x: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(sinf(x)));
+    return @floatCast(sinf(x));
 }
 
 pub fn sinf(x: f32) callconv(.C) f32 {
@@ -41,7 +41,7 @@ pub fn sinf(x: f32) callconv(.C) f32 {
     const s3pio2: f64 = 3.0 * math.pi / 2.0; // 0x4012D97C, 0x7F3321D2
     const s4pio2: f64 = 4.0 * math.pi / 2.0; // 0x401921FB, 0x54442D18
 
-    var ix = @as(u32, @bitCast(x));
+    var ix: u32 = @bitCast(x);
     const sign = ix >> 31 != 0;
     ix &= 0x7fffffff;
 
@@ -120,12 +120,12 @@ pub fn sin(x: f64) callconv(.C) f64 {
 
 pub fn __sinx(x: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(sinq(x)));
+    return @floatCast(sinq(x));
 }
 
 pub fn sinq(x: f128) callconv(.C) f128 {
     // TODO: more correct implementation
-    return sin(@as(f64, @floatCast(x)));
+    return sin(@floatCast(x));
 }
 
 pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble {
@@ -180,11 +180,11 @@ test "sin64.special" {
 }
 
 test "sin32 #9901" {
-    const float = @as(f32, @bitCast(@as(u32, 0b11100011111111110000000000000000)));
+    const float: f32 = @bitCast(@as(u32, 0b11100011111111110000000000000000));
     _ = sinf(float);
 }
 
 test "sin64 #9901" {
-    const float = @as(f64, @bitCast(@as(u64, 0b1111111101000001000000001111110111111111100000000000000000000001)));
+    const float: f64 = @bitCast(@as(u64, 0b1111111101000001000000001111110111111111100000000000000000000001));
     _ = sin(float);
 }
lib/compiler_rt/sqrt.zig
@@ -20,13 +20,13 @@ comptime {
 
 pub fn __sqrth(x: f16) callconv(.C) f16 {
     // TODO: more efficient implementation
-    return @as(f16, @floatCast(sqrtf(x)));
+    return @floatCast(sqrtf(x));
 }
 
 pub fn sqrtf(x: f32) callconv(.C) f32 {
     const tiny: f32 = 1.0e-30;
-    const sign: i32 = @as(i32, @bitCast(@as(u32, 0x80000000)));
-    var ix: i32 = @as(i32, @bitCast(x));
+    const sign: i32 = @bitCast(@as(u32, 0x80000000));
+    var ix: i32 = @bitCast(x);
 
     if ((ix & 0x7F800000) == 0x7F800000) {
         return x * x + x; // sqrt(nan) = nan, sqrt(+inf) = +inf, sqrt(-inf) = nan
@@ -96,7 +96,7 @@ pub fn sqrtf(x: f32) callconv(.C) f32 {
 
     ix = (q >> 1) + 0x3f000000;
     ix += m << 23;
-    return @as(f32, @bitCast(ix));
+    return @bitCast(ix);
 }
 
 /// NOTE: The original code is full of implicit signed -> unsigned assumptions and u32 wraparound
@@ -105,10 +105,10 @@ pub fn sqrtf(x: f32) callconv(.C) f32 {
 pub fn sqrt(x: f64) callconv(.C) f64 {
     const tiny: f64 = 1.0e-300;
     const sign: u32 = 0x80000000;
-    const u = @as(u64, @bitCast(x));
+    const u: u64 = @bitCast(x);
 
-    var ix0 = @as(u32, @intCast(u >> 32));
-    var ix1 = @as(u32, @intCast(u & 0xFFFFFFFF));
+    var ix0: u32 = @intCast(u >> 32);
+    var ix1: u32 = @intCast(u & 0xFFFFFFFF);
 
     // sqrt(nan) = nan, sqrt(+inf) = +inf, sqrt(-inf) = nan
     if (ix0 & 0x7FF00000 == 0x7FF00000) {
@@ -140,8 +140,8 @@ pub fn sqrt(x: f64) callconv(.C) f64 {
             ix0 <<= 1;
         }
         m -= @as(i32, @intCast(i)) - 1;
-        ix0 |= ix1 >> @as(u5, @intCast(32 - i));
-        ix1 <<= @as(u5, @intCast(i));
+        ix0 |= ix1 >> @intCast(32 - i);
+        ix1 <<= @intCast(i);
     }
 
     // unbias exponent
@@ -225,21 +225,21 @@ pub fn sqrt(x: f64) callconv(.C) f64 {
 
     // NOTE: musl here appears to rely on signed twos-complement wraparound. +% has the same
     // behaviour at least.
-    var iix0 = @as(i32, @intCast(ix0));
+    var iix0: i32 = @intCast(ix0);
     iix0 = iix0 +% (m << 20);
 
     const uz = (@as(u64, @intCast(iix0)) << 32) | ix1;
-    return @as(f64, @bitCast(uz));
+    return @bitCast(uz);
 }
 
 pub fn __sqrtx(x: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(sqrtq(x)));
+    return @floatCast(sqrtq(x));
 }
 
 pub fn sqrtq(x: f128) callconv(.C) f128 {
     // TODO: more correct implementation
-    return sqrt(@as(f64, @floatCast(x)));
+    return sqrt(@floatCast(x));
 }
 
 pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble {
lib/compiler_rt/tan.zig
@@ -106,12 +106,12 @@ pub fn tan(x: f64) callconv(.C) f64 {
 
 pub fn __tanx(x: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(tanq(x)));
+    return @floatCast(tanq(x));
 }
 
 pub fn tanq(x: f128) callconv(.C) f128 {
     // TODO: more correct implementation
-    return tan(@as(f64, @floatCast(x)));
+    return tan(@floatCast(x));
 }
 
 pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble {
lib/compiler_rt/trig.zig
@@ -70,7 +70,7 @@ pub fn __cosdf(x: f64) f32 {
     const z = x * x;
     const w = z * z;
     const r = C2 + z * C3;
-    return @as(f32, @floatCast(((1.0 + z * C0) + w * C1) + (w * z) * r));
+    return @floatCast(((1.0 + z * C0) + w * C1) + (w * z) * r);
 }
 
 /// kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
@@ -131,7 +131,7 @@ pub fn __sindf(x: f64) f32 {
     const w = z * z;
     const r = S3 + z * S4;
     const s = z * x;
-    return @as(f32, @floatCast((x + s * (S1 + z * S2)) + s * w * r));
+    return @floatCast((x + s * (S1 + z * S2)) + s * w * r);
 }
 
 /// kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
@@ -231,11 +231,11 @@ pub fn __tan(x_: f64, y_: f64, odd: bool) f64 {
     }
     // -1.0/(x+r) has up to 2ulp error, so compute it accurately
     w0 = w;
-    w0 = @as(f64, @bitCast(@as(u64, @bitCast(w0)) & 0xffffffff00000000));
+    w0 = @bitCast(@as(u64, @bitCast(w0)) & 0xffffffff00000000);
     v = r - (w0 - x); // w0+v = r+x
     a = -1.0 / w;
     a0 = a;
-    a0 = @as(f64, @bitCast(@as(u64, @bitCast(a0)) & 0xffffffff00000000));
+    a0 = @bitCast(@as(u64, @bitCast(a0)) & 0xffffffff00000000);
     return a0 + a * (1.0 + a0 * w0 + a0 * v);
 }
 
@@ -269,5 +269,5 @@ pub fn __tandf(x: f64, odd: bool) f32 {
     const s = z * x;
     const u = T[0] + z * T[1];
     const r0 = (x + s * u) + (s * w) * (t + w * r);
-    return @as(f32, @floatCast(if (odd) -1.0 / r0 else r0));
+    return @floatCast(if (odd) -1.0 / r0 else r0);
 }
lib/compiler_rt/trunc.zig
@@ -42,7 +42,7 @@ pub fn truncf(x: f32) callconv(.C) f32 {
         e = 1;
     }
 
-    m = @as(u32, math.maxInt(u32)) >> @as(u5, @intCast(e));
+    m = @as(u32, math.maxInt(u32)) >> @intCast(e);
     if (u & m == 0) {
         return x;
     } else {
@@ -63,7 +63,7 @@ pub fn trunc(x: f64) callconv(.C) f64 {
         e = 1;
     }
 
-    m = @as(u64, math.maxInt(u64)) >> @as(u6, @intCast(e));
+    m = @as(u64, math.maxInt(u64)) >> @intCast(e);
     if (u & m == 0) {
         return x;
     } else {
@@ -74,11 +74,11 @@ pub fn trunc(x: f64) callconv(.C) f64 {
 
 pub fn __truncx(x: f80) callconv(.C) f80 {
     // TODO: more efficient implementation
-    return @as(f80, @floatCast(truncq(x)));
+    return @floatCast(truncq(x));
 }
 
 pub fn truncq(x: f128) callconv(.C) f128 {
-    const u = @as(u128, @bitCast(x));
+    const u: u128 = @bitCast(x);
     var e = @as(i32, @intCast(((u >> 112) & 0x7FFF))) - 0x3FFF + 16;
     var m: u128 = undefined;
 
@@ -89,12 +89,12 @@ pub fn truncq(x: f128) callconv(.C) f128 {
         e = 1;
     }
 
-    m = @as(u128, math.maxInt(u128)) >> @as(u7, @intCast(e));
+    m = @as(u128, math.maxInt(u128)) >> @intCast(e);
     if (u & m == 0) {
         return x;
     } else {
         math.doNotOptimizeAway(x + 0x1p120);
-        return @as(f128, @bitCast(u & ~m));
+        return @bitCast(u & ~m);
     }
 }
 
lib/compiler_rt/truncdfhf2.zig
@@ -12,9 +12,9 @@ comptime {
 }
 
 pub fn __truncdfhf2(a: f64) callconv(.C) common.F16T(f64) {
-    return @as(common.F16T(f64), @bitCast(truncf(f16, f64, a)));
+    return @bitCast(truncf(f16, f64, a));
 }
 
 fn __aeabi_d2h(a: f64) callconv(.AAPCS) u16 {
-    return @as(common.F16T(f64), @bitCast(truncf(f16, f64, a)));
+    return @bitCast(truncf(f16, f64, a));
 }
lib/compiler_rt/truncf.zig
@@ -5,7 +5,6 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
     const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
     const srcSigBits = std.math.floatMantissaBits(src_t);
     const dstSigBits = std.math.floatMantissaBits(dst_t);
-    const SrcShift = std.math.Log2Int(src_rep_t);
 
     // Various constants whose values follow from the type parameters.
     // Any reasonable optimizer will fold and propagate all of these.
@@ -38,7 +37,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
     const dstNaNCode = dstQNaN - 1;
 
     // Break a into a sign and representation of the absolute value
-    const aRep: src_rep_t = @as(src_rep_t, @bitCast(a));
+    const aRep: src_rep_t = @bitCast(a);
     const aAbs: src_rep_t = aRep & srcAbsMask;
     const sign: src_rep_t = aRep & srcSignMask;
     var absResult: dst_rep_t = undefined;
@@ -47,7 +46,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
         // The exponent of a is within the range of normal numbers in the
         // destination format.  We can convert by simply right-shifting with
         // rounding and adjusting the exponent.
-        absResult = @as(dst_rep_t, @truncate(aAbs >> (srcSigBits - dstSigBits)));
+        absResult = @truncate(aAbs >> (srcSigBits - dstSigBits));
         absResult -%= @as(dst_rep_t, srcExpBias - dstExpBias) << dstSigBits;
 
         const roundBits: src_rep_t = aAbs & roundMask;
@@ -64,7 +63,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
         // bit and inserting the (truncated) trailing NaN field.
         absResult = @as(dst_rep_t, @intCast(dstInfExp)) << dstSigBits;
         absResult |= dstQNaN;
-        absResult |= @as(dst_rep_t, @intCast(((aAbs & srcNaNCode) >> (srcSigBits - dstSigBits)) & dstNaNCode));
+        absResult |= @intCast(((aAbs & srcNaNCode) >> (srcSigBits - dstSigBits)) & dstNaNCode);
     } else if (aAbs >= overflow) {
         // a overflows to infinity.
         absResult = @as(dst_rep_t, @intCast(dstInfExp)) << dstSigBits;
@@ -81,9 +80,9 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
         if (shift > srcSigBits) {
             absResult = 0;
         } else {
-            const sticky: src_rep_t = @intFromBool(significand << @as(SrcShift, @intCast(srcBits - shift)) != 0);
-            const denormalizedSignificand: src_rep_t = significand >> @as(SrcShift, @intCast(shift)) | sticky;
-            absResult = @as(dst_rep_t, @intCast(denormalizedSignificand >> (srcSigBits - dstSigBits)));
+            const sticky: src_rep_t = @intFromBool(significand << @intCast(srcBits - shift) != 0);
+            const denormalizedSignificand: src_rep_t = significand >> @intCast(shift) | sticky;
+            absResult = @intCast(denormalizedSignificand >> (srcSigBits - dstSigBits));
             const roundBits: src_rep_t = denormalizedSignificand & roundMask;
             if (roundBits > halfway) {
                 // Round to nearest
@@ -96,8 +95,8 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
     }
 
     const result: dst_rep_t align(@alignOf(dst_t)) = absResult |
-        @as(dst_rep_t, @truncate(sign >> @as(SrcShift, @intCast(srcBits - dstBits))));
-    return @as(dst_t, @bitCast(result));
+        @as(dst_rep_t, @truncate(sign >> @intCast(srcBits - dstBits)));
+    return @bitCast(result);
 }
 
 pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
@@ -133,7 +132,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
         // destination format.  We can convert by simply right-shifting with
         // rounding and adjusting the exponent.
         abs_result = @as(dst_rep_t, a_rep.exp) << dst_sig_bits;
-        abs_result |= @as(dst_rep_t, @truncate(a_rep.fraction >> (src_sig_bits - dst_sig_bits)));
+        abs_result |= @truncate(a_rep.fraction >> (src_sig_bits - dst_sig_bits));
         abs_result -%= @as(dst_rep_t, src_exp_bias - dst_exp_bias) << dst_sig_bits;
 
         const round_bits = a_rep.fraction & round_mask;
@@ -150,7 +149,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
         // bit and inserting the (truncated) trailing NaN field.
         abs_result = @as(dst_rep_t, @intCast(dst_inf_exp)) << dst_sig_bits;
         abs_result |= dst_qnan;
-        abs_result |= @as(dst_rep_t, @intCast((a_rep.fraction >> (src_sig_bits - dst_sig_bits)) & dst_nan_mask));
+        abs_result |= @intCast((a_rep.fraction >> (src_sig_bits - dst_sig_bits)) & dst_nan_mask);
     } else if (a_rep.exp >= overflow) {
         // a overflows to infinity.
         abs_result = @as(dst_rep_t, @intCast(dst_inf_exp)) << dst_sig_bits;
@@ -164,9 +163,9 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
         if (shift > src_sig_bits) {
             abs_result = 0;
         } else {
-            const sticky = @intFromBool(a_rep.fraction << @as(u6, @intCast(shift)) != 0);
-            const denormalized_significand = a_rep.fraction >> @as(u6, @intCast(shift)) | sticky;
-            abs_result = @as(dst_rep_t, @intCast(denormalized_significand >> (src_sig_bits - dst_sig_bits)));
+            const sticky = @intFromBool(a_rep.fraction << @intCast(shift) != 0);
+            const denormalized_significand = a_rep.fraction >> @intCast(shift) | sticky;
+            abs_result = @intCast(denormalized_significand >> (src_sig_bits - dst_sig_bits));
             const round_bits = denormalized_significand & round_mask;
             if (round_bits > halfway) {
                 // Round to nearest
@@ -179,7 +178,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
     }
 
     const result align(@alignOf(dst_t)) = abs_result | @as(dst_rep_t, sign) << dst_bits - 16;
-    return @as(dst_t, @bitCast(result));
+    return @bitCast(result);
 }
 
 test {
lib/compiler_rt/truncsfhf2.zig
@@ -13,13 +13,13 @@ comptime {
 }
 
 pub fn __truncsfhf2(a: f32) callconv(.C) common.F16T(f32) {
-    return @as(common.F16T(f32), @bitCast(truncf(f16, f32, a)));
+    return @bitCast(truncf(f16, f32, a));
 }
 
 fn __gnu_f2h_ieee(a: f32) callconv(.C) common.F16T(f32) {
-    return @as(common.F16T(f32), @bitCast(truncf(f16, f32, a)));
+    return @bitCast(truncf(f16, f32, a));
 }
 
 fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
-    return @as(common.F16T(f32), @bitCast(truncf(f16, f32, a)));
+    return @bitCast(truncf(f16, f32, a));
 }
lib/compiler_rt/trunctfhf2.zig
@@ -8,5 +8,5 @@ comptime {
 }
 
 pub fn __trunctfhf2(a: f128) callconv(.C) common.F16T(f128) {
-    return @as(common.F16T(f128), @bitCast(truncf(f16, f128, a)));
+    return @bitCast(truncf(f16, f128, a));
 }
lib/compiler_rt/truncxfhf2.zig
@@ -8,5 +8,5 @@ comptime {
 }
 
 fn __truncxfhf2(a: f80) callconv(.C) common.F16T(f80) {
-    return @as(common.F16T(f80), @bitCast(trunc_f80(f16, a)));
+    return @bitCast(trunc_f80(f16, a));
 }
lib/compiler_rt/udivmod.zig
@@ -21,11 +21,11 @@ fn divwide_generic(comptime T: type, _u1: T, _u0: T, v_: T, r: *T) T {
     var un64: T = undefined;
     var un10: T = undefined;
 
-    const s = @as(Log2Int(T), @intCast(@clz(v)));
+    const s: Log2Int(T) = @intCast(@clz(v));
     if (s > 0) {
         // Normalize divisor
         v <<= s;
-        un64 = (_u1 << s) | (_u0 >> @as(Log2Int(T), @intCast((@bitSizeOf(T) - @as(T, @intCast(s))))));
+        un64 = (_u1 << s) | (_u0 >> @intCast((@bitSizeOf(T) - @as(T, @intCast(s)))));
         un10 = _u0 << s;
     } else {
         // Avoid undefined behavior of (u0 >> @bitSizeOf(T))
@@ -101,8 +101,8 @@ pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T {
         return 0;
     }
 
-    var a = @as([2]HalfT, @bitCast(a_));
-    var b = @as([2]HalfT, @bitCast(b_));
+    var a: [2]HalfT = @bitCast(a_);
+    var b: [2]HalfT = @bitCast(b_);
     var q: [2]HalfT = undefined;
     var r: [2]HalfT = undefined;
 
@@ -119,16 +119,16 @@ pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T {
             q[lo] = divwide(HalfT, a[hi] % b[lo], a[lo], b[lo], &r[lo]);
         }
         if (maybe_rem) |rem| {
-            rem.* = @as(T, @bitCast(r));
+            rem.* = @bitCast(r);
         }
-        return @as(T, @bitCast(q));
+        return @bitCast(q);
     }
 
     // 0 <= shift <= 63
     var shift: Log2Int(T) = @clz(b[hi]) - @clz(a[hi]);
-    var af = @as(T, @bitCast(a));
+    var af: T = @bitCast(a);
     var bf = @as(T, @bitCast(b)) << shift;
-    q = @as([2]HalfT, @bitCast(@as(T, 0)));
+    q = @bitCast(@as(T, 0));
 
     for (0..shift + 1) |_| {
         q[lo] <<= 1;
@@ -138,12 +138,12 @@ pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T {
         //     q[lo] |= 1;
         // }
         const s = @as(SignedT, @bitCast(bf -% af -% 1)) >> (@bitSizeOf(T) - 1);
-        q[lo] |= @as(HalfT, @intCast(s & 1));
+        q[lo] |= @intCast(s & 1);
         af -= bf & @as(T, @bitCast(s));
         bf >>= 1;
     }
     if (maybe_rem) |rem| {
-        rem.* = @as(T, @bitCast(af));
+        rem.* = @bitCast(af);
     }
-    return @as(T, @bitCast(q));
+    return @bitCast(q);
 }
lib/compiler_rt/udivmodti4.zig
@@ -20,7 +20,7 @@ pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __udivmodti4_windows_x86_64(a: v2u64, b: v2u64, maybe_rem: ?*u128) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(udivmod(u128, @as(u128, @bitCast(a)), @as(u128, @bitCast(b)), maybe_rem)));
+    return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), maybe_rem));
 }
 
 test {
lib/compiler_rt/udivti3.zig
@@ -20,5 +20,5 @@ pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 {
 const v2u64 = @Vector(2, u64);
 
 fn __udivti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.C) v2u64 {
-    return @as(v2u64, @bitCast(udivmod(u128, @as(u128, @bitCast(a)), @as(u128, @bitCast(b)), null)));
+    return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), null));
 }
lib/compiler_rt/umodti3.zig
@@ -23,6 +23,6 @@ const v2u64 = @Vector(2, u64);
 
 fn __umodti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.C) v2u64 {
     var r: u128 = undefined;
-    _ = udivmod(u128, @as(u128, @bitCast(a)), @as(u128, @bitCast(b)), &r);
-    return @as(v2u64, @bitCast(r));
+    _ = udivmod(u128, @bitCast(a), @bitCast(b), &r);
+    return @bitCast(r);
 }