-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13074 from topolarity/stage2-opt
stage2: Miscellaneous fixes to vector arithmetic and copy elision
- Loading branch information
Showing
12 changed files
with
522 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const std = @import("std"); | ||
const expect = std.testing.expect; | ||
|
||
var ok = false; | ||
fn foo(x: anytype) void { | ||
ok = x; | ||
} | ||
test { | ||
const x = &foo; | ||
x(true); | ||
try expect(ok); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const std = @import("std"); | ||
const expect = std.testing.expect; | ||
|
||
var pos = [2]f32{ 0.0, 0.0 }; | ||
test "store to global array" { | ||
try expect(pos[1] == 0.0); | ||
pos = [2]f32{ 0.0, 1.0 }; | ||
try expect(pos[1] == 1.0); | ||
} | ||
|
||
var vpos = @Vector(2, f32){ 0.0, 0.0 }; | ||
test "store to global vector" { | ||
try expect(vpos[1] == 0.0); | ||
vpos = @Vector(2, f32){ 0.0, 1.0 }; | ||
try expect(vpos[1] == 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const std = @import("std"); | ||
const builtin = @import("builtin"); | ||
const expect = std.testing.expect; | ||
|
||
test { | ||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
|
||
var x: [10][10]u32 = undefined; | ||
|
||
x[0][1] = 0; | ||
const a = x[0]; | ||
x[0][1] = 15; | ||
|
||
try expect(a[1] == 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const std = @import("std"); | ||
const builtin = @import("builtin"); | ||
const expect = std.testing.expect; | ||
|
||
const U = union(enum) { | ||
array: [10]u32, | ||
other: u32, | ||
}; | ||
|
||
test { | ||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
|
||
var x = U{ .array = undefined }; | ||
|
||
x.array[1] = 0; | ||
const a = x.array; | ||
x.array[1] = 15; | ||
|
||
try expect(a[1] == 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const std = @import("std"); | ||
const builtin = @import("builtin"); | ||
const expect = std.testing.expect; | ||
|
||
test { | ||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
|
||
var opt_x: ?[3]f32 = [_]f32{0.0} ** 3; | ||
|
||
const x = opt_x.?; | ||
opt_x.?[0] = 15.0; | ||
|
||
try expect(x[0] == 0.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters