aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorMarc Tiehuis <marctiehuis@gmail.com>2018-06-30 20:06:30 +1200
committerMarc Tiehuis <marctiehuis@gmail.com>2018-06-30 21:58:59 +1200
commit9f48b2ab48bcd6cfba45b8dfc60d0ad9633b294e (patch)
treef4b01cbfcebc40284d0b7fe7aec3f371e32fc799 /std
parent814a34f263cbfeabbf7a898b3b70fa781baaccac (diff)
downloadzig-9f48b2ab48bcd6cfba45b8dfc60d0ad9633b294e.tar.gz
zig-9f48b2ab48bcd6cfba45b8dfc60d0ad9633b294e.zip
compiler_rt: Remove wrapping add/sub operators where unneeded
Closes #495.
Diffstat (limited to 'std')
-rw-r--r--std/special/compiler_rt/floattidf.zig4
-rw-r--r--std/special/compiler_rt/floattisf.zig4
-rw-r--r--std/special/compiler_rt/floattitf.zig4
-rw-r--r--std/special/compiler_rt/floatunditf.zig2
-rw-r--r--std/special/compiler_rt/floatunsitf.zig2
-rw-r--r--std/special/compiler_rt/floatuntidf.zig16
-rw-r--r--std/special/compiler_rt/floatuntisf.zig16
-rw-r--r--std/special/compiler_rt/floatuntitf.zig16
8 files changed, 32 insertions, 32 deletions
diff --git a/std/special/compiler_rt/floattidf.zig b/std/special/compiler_rt/floattidf.zig
index 8a627fdc04..2a24c64efe 100644
--- a/std/special/compiler_rt/floattidf.zig
+++ b/std/special/compiler_rt/floattidf.zig
@@ -42,12 +42,12 @@ pub extern fn __floattidf(arg: i128) f64 {
}
// finish
a |= @boolToInt((a & 4) != 0); // Or P into R
- a +%= 1; // round - this step may add a significant bit
+ a += 1; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits
if ((a & (u128(1) << DBL_MANT_DIG)) != 0) {
a >>= 1;
- e +%= 1;
+ e += 1;
}
// a is now rounded to DBL_MANT_DIG bits
} else {
diff --git a/std/special/compiler_rt/floattisf.zig b/std/special/compiler_rt/floattisf.zig
index cbdd30418f..4618a86444 100644
--- a/std/special/compiler_rt/floattisf.zig
+++ b/std/special/compiler_rt/floattisf.zig
@@ -43,12 +43,12 @@ pub extern fn __floattisf(arg: i128) f32 {
}
// finish
a |= @boolToInt((a & 4) != 0); // Or P into R
- a +%= 1; // round - this step may add a significant bit
+ a += 1; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits
if ((a & (u128(1) << FLT_MANT_DIG)) != 0) {
a >>= 1;
- e +%= 1;
+ e += 1;
}
// a is now rounded to FLT_MANT_DIG bits
} else {
diff --git a/std/special/compiler_rt/floattitf.zig b/std/special/compiler_rt/floattitf.zig
index 531634e494..4da2c145fa 100644
--- a/std/special/compiler_rt/floattitf.zig
+++ b/std/special/compiler_rt/floattitf.zig
@@ -42,12 +42,12 @@ pub extern fn __floattitf(arg: i128) f128 {
}
// finish
a |= @boolToInt((a & 4) != 0); // Or P into R
- a +%= 1; // round - this step may add a significant bit
+ a += 1; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits
if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) {
a >>= 1;
- e +%= 1;
+ e += 1;
}
// a is now rounded to LDBL_MANT_DIG bits
} else {
diff --git a/std/special/compiler_rt/floatunditf.zig b/std/special/compiler_rt/floatunditf.zig
index b8b097581f..12d6a5613f 100644
--- a/std/special/compiler_rt/floatunditf.zig
+++ b/std/special/compiler_rt/floatunditf.zig
@@ -1,6 +1,6 @@
const builtin = @import("builtin");
const is_test = builtin.is_test;
-const std = @import("../../index.zig");
+const std = @import("std");
pub extern fn __floatunditf(a: u128) f128 {
@setRuntimeSafety(is_test);
diff --git a/std/special/compiler_rt/floatunsitf.zig b/std/special/compiler_rt/floatunsitf.zig
index dfee826b32..625f90a3d0 100644
--- a/std/special/compiler_rt/floatunsitf.zig
+++ b/std/special/compiler_rt/floatunsitf.zig
@@ -1,6 +1,6 @@
const builtin = @import("builtin");
const is_test = builtin.is_test;
-const std = @import("../../index.zig");
+const std = @import("std");
pub extern fn __floatunsitf(a: u64) f128 {
@setRuntimeSafety(is_test);
diff --git a/std/special/compiler_rt/floatuntidf.zig b/std/special/compiler_rt/floatuntidf.zig
index 3aabcb7b8a..1101733825 100644
--- a/std/special/compiler_rt/floatuntidf.zig
+++ b/std/special/compiler_rt/floatuntidf.zig
@@ -11,8 +11,8 @@ pub extern fn __floatuntidf(arg: u128) f64 {
var a = arg;
const N: u32 = @sizeOf(u128) * 8;
- const sd = @bitCast(i32, N -% @clz(a)); // number of significant digits
- var e: i32 = sd -% 1; // exponent
+ const sd = @bitCast(i32, N - @clz(a)); // number of significant digits
+ var e: i32 = sd - 1; // exponent
if (sd > DBL_MANT_DIG) {
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
@@ -27,28 +27,28 @@ pub extern fn __floatuntidf(arg: u128) f64 {
},
DBL_MANT_DIG + 2 => {},
else => {
- const shift_amt = @bitCast(i32, N +% (DBL_MANT_DIG + 2)) -% sd;
+ const shift_amt = @bitCast(i32, N + (DBL_MANT_DIG + 2)) - sd;
const shift_amt_u7 = @intCast(u7, shift_amt);
- a = (a >> @intCast(u7, sd -% (DBL_MANT_DIG + 2))) |
+ a = (a >> @intCast(u7, sd - (DBL_MANT_DIG + 2))) |
@boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0);
},
}
// finish
a |= @boolToInt((a & 4) != 0); // Or P into R
- a +%= 1; // round - this step may add a significant bit
+ a += 1; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits
if ((a & (u128(1) << DBL_MANT_DIG)) != 0) {
a >>= 1;
- e +%= 1;
+ e += 1;
}
// a is now rounded to DBL_MANT_DIG bits
} else {
- a <<= @intCast(u7, DBL_MANT_DIG -% sd);
+ a <<= @intCast(u7, DBL_MANT_DIG - sd);
// a is now rounded to DBL_MANT_DIG bits
}
- const high: u64 = @bitCast(u32, (e +% 1023) << 20) | // exponent
+ const high: u64 = @bitCast(u32, (e + 1023) << 20) | // exponent
(@truncate(u32, a >> 32) & 0x000FFFFF); // mantissa-high
const low = @truncate(u32, a); // mantissa-low
diff --git a/std/special/compiler_rt/floatuntisf.zig b/std/special/compiler_rt/floatuntisf.zig
index e83affd87c..f85c22578e 100644
--- a/std/special/compiler_rt/floatuntisf.zig
+++ b/std/special/compiler_rt/floatuntisf.zig
@@ -11,8 +11,8 @@ pub extern fn __floatuntisf(arg: u128) f32 {
var a = arg;
const N: u32 = @sizeOf(u128) * 8;
- const sd = @bitCast(i32, N -% @clz(a)); // number of significant digits
- var e: i32 = sd -% 1; // exponent
+ const sd = @bitCast(i32, N - @clz(a)); // number of significant digits
+ var e: i32 = sd - 1; // exponent
if (sd > FLT_MANT_DIG) {
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
@@ -27,28 +27,28 @@ pub extern fn __floatuntisf(arg: u128) f32 {
},
FLT_MANT_DIG + 2 => {},
else => {
- const shift_amt = @bitCast(i32, N +% (FLT_MANT_DIG + 2)) -% sd;
+ const shift_amt = @bitCast(i32, N + (FLT_MANT_DIG + 2)) - sd;
const shift_amt_u7 = @intCast(u7, shift_amt);
- a = (a >> @intCast(u7, sd -% (FLT_MANT_DIG + 2))) |
+ a = (a >> @intCast(u7, sd - (FLT_MANT_DIG + 2))) |
@boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0);
},
}
// finish
a |= @boolToInt((a & 4) != 0); // Or P into R
- a +%= 1; // round - this step may add a significant bit
+ a += 1; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits
if ((a & (u128(1) << FLT_MANT_DIG)) != 0) {
a >>= 1;
- e +%= 1;
+ e += 1;
}
// a is now rounded to FLT_MANT_DIG bits
} else {
- a <<= @intCast(u7, FLT_MANT_DIG -% sd);
+ a <<= @intCast(u7, FLT_MANT_DIG - sd);
// a is now rounded to FLT_MANT_DIG bits
}
- const high = @bitCast(u32, (e +% 127) << 23); // exponent
+ const high = @bitCast(u32, (e + 127) << 23); // exponent
const low = @truncate(u32, a) & 0x007fffff; // mantissa
return @bitCast(f32, high | low);
diff --git a/std/special/compiler_rt/floatuntitf.zig b/std/special/compiler_rt/floatuntitf.zig
index a64dd96a34..6354c89287 100644
--- a/std/special/compiler_rt/floatuntitf.zig
+++ b/std/special/compiler_rt/floatuntitf.zig
@@ -11,8 +11,8 @@ pub extern fn __floatuntitf(arg: u128) f128 {
var a = arg;
const N: u32 = @sizeOf(u128) * 8;
- const sd = @bitCast(i32, N -% @clz(a)); // number of significant digits
- var e: i32 = sd -% 1; // exponent
+ const sd = @bitCast(i32, N - @clz(a)); // number of significant digits
+ var e: i32 = sd - 1; // exponent
if (sd > LDBL_MANT_DIG) {
// start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
// finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
@@ -27,28 +27,28 @@ pub extern fn __floatuntitf(arg: u128) f128 {
},
LDBL_MANT_DIG + 2 => {},
else => {
- const shift_amt = @bitCast(i32, N +% (LDBL_MANT_DIG + 2)) -% sd;
+ const shift_amt = @bitCast(i32, N + (LDBL_MANT_DIG + 2)) - sd;
const shift_amt_u7 = @intCast(u7, shift_amt);
- a = (a >> @intCast(u7, sd -% (LDBL_MANT_DIG + 2))) |
+ a = (a >> @intCast(u7, sd - (LDBL_MANT_DIG + 2))) |
@boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0);
},
}
// finish
a |= @boolToInt((a & 4) != 0); // Or P into R
- a +%= 1; // round - this step may add a significant bit
+ a += 1; // round - this step may add a significant bit
a >>= 2; // dump Q and R
// a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits
if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) {
a >>= 1;
- e +%= 1;
+ e += 1;
}
// a is now rounded to LDBL_MANT_DIG bits
} else {
- a <<= @intCast(u7, LDBL_MANT_DIG -% sd);
+ a <<= @intCast(u7, LDBL_MANT_DIG - sd);
// a is now rounded to LDBL_MANT_DIG bits
}
- const high: u128 = (@intCast(u64, (e +% 16383)) << 48) | // exponent
+ const high: u128 = (@intCast(u64, (e + 16383)) << 48) | // exponent
(@truncate(u64, a >> 64) & 0x0000ffffffffffff); // mantissa-high
const low = @truncate(u64, a); // mantissa-low