CBE: fix bitwise not

Closes #13911
This commit is contained in:
Jacob Young
2022-12-20 21:31:44 -05:00
committed by Andrew Kelley
parent 471f3c470f
commit a52dcdd3c5
2 changed files with 18 additions and 2 deletions

View File

@@ -532,6 +532,19 @@ fn testUnsignedNegationWrappingEval(x: u16) !void {
try expect(neg == maxInt(u16));
}
test "negation wrapping" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
try expectEqual(@as(u1, 1), negateWrap(u1, 1));
}
fn negateWrap(comptime T: type, x: T) T {
// This is specifically testing a safety-checked add, so
// special case minInt(T) which would overflow otherwise.
return if (x == minInt(T)) minInt(T) else ~x + 1;
}
test "unsigned 64-bit division" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO