Skip to content

Commit

Permalink
respond to vegecode's review
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnl committed Apr 10, 2019
1 parent 3e0c330 commit e90f46e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion std/special/compiler_rt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ comptime {
@export("__getf2", @import("compiler_rt/comparetf2.zig").__getf2, linkage);

if (!is_test) {
// only create these aliases when not testing -- Yes, I can read the code, but why?
// Why don't we need these when testing?
@export("__cmptf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
@export("__eqtf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
@export("__lttf2", @import("compiler_rt/comparetf2.zig").__letf2, linkage);
Expand Down
8 changes: 4 additions & 4 deletions std/special/compiler_rt/addXf3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ pub extern fn __subtf3(a: f128, b: f128) f128 {
// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
const Z = @IntType(false, T.bit_count);
const S = @IntType(false, T.bit_count - @clz(@IntType(false, T.bit_count), Z(T.bit_count) - 1));
const S = @IntType(false, T.bit_count - @clz(Z, Z(T.bit_count) - 1));
const significandBits = std.math.floatMantissaBits(T);
const implicitBit = Z(1) << significandBits;

const shift = @clz(@IntType(false, T.bit_count), significand.*) - @clz(@IntType(false, T.bit_count), implicitBit);
const shift = @clz(@IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit);
significand.* <<= @intCast(S, shift);
return 1 - shift;
}

// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
fn addXf3(comptime T: type, a: T, b: T) T {
const Z = @IntType(false, T.bit_count);
const S = @IntType(false, T.bit_count - @clz(@IntType(false, T.bit_count), Z(T.bit_count) - 1));
const S = @IntType(false, T.bit_count - @clz(Z, Z(T.bit_count) - 1));

const typeWidth = T.bit_count;
const significandBits = std.math.floatMantissaBits(T);
Expand Down Expand Up @@ -162,7 +162,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
// If partial cancellation occured, we need to left-shift the result
// and adjust the exponent:
if (aSignificand < implicitBit << 3) {
const shift = @intCast(i32, @clz(@IntType(false, T.bit_count), aSignificand)) - @intCast(i32, @clz(@IntType(false, T.bit_count), implicitBit << 3));
const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(@IntType(false, T.bit_count), implicitBit << 3));
aSignificand <<= @intCast(S, shift);
aExponent -= shift;
}
Expand Down
4 changes: 2 additions & 2 deletions std/special/compiler_rt/extendXfYf2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_
// 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(@IntType(false, @typeInfo(src_t).Float.bits), aAbs) -
@clz(@IntType(false, @typeInfo(src_t).Float.bits), src_rep_t(srcMinNormal));
const scale: u32 = @clz(src_rep_t, aAbs) -
@clz(src_rep_t, src_rep_t(srcMinNormal));
absResult = dst_rep_t(aAbs) << @intCast(DstShift, dstSigBits - srcSigBits + scale);
absResult ^= dstMinNormal;
const resultExponent: u32 = dstExpBias - srcExpBias - scale + 1;
Expand Down
2 changes: 1 addition & 1 deletion std/special/compiler_rt/mulXf3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn normalize(comptime T: type, significand: *@IntType(false, T.bit_count)) i32 {
const significandBits = std.math.floatMantissaBits(T);
const implicitBit = Z(1) << significandBits;

const shift = @clz(@IntType(false, T.bit_count), significand.*) - @clz(@IntType(false, T.bit_count), implicitBit);
const shift = @clz(Z, significand.*) - @clz(Z, implicitBit);
significand.* <<= @intCast(std.math.Log2Int(Z), shift);
return 1 - shift;
}
Expand Down

0 comments on commit e90f46e

Please sign in to comment.