From 0f7ef348e01759b33b520a539a9a2daa26869c2d Mon Sep 17 00:00:00 2001 From: "Ben L. Titzer" Date: Sat, 19 Oct 2024 12:37:29 -0500 Subject: [PATCH] Add test for optimizing first-class view operation --- doc/allopts.txt | 1 + test/core/opt_view00.v3 | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 test/core/opt_view00.v3 diff --git a/doc/allopts.txt b/doc/allopts.txt index 2cc2b017f..e6e4747eb 100644 --- a/doc/allopts.txt +++ b/doc/allopts.txt @@ -30,6 +30,7 @@ local misc combine adjacent loads/stores byteswap recognition reorder bounds checks of a[0], a[1], a[2]... + ordering of strength-reduction and direct call recording (inlining) local control flow optimizations * branch folding diff --git a/test/core/opt_view00.v3 b/test/core/opt_view00.v3 new file mode 100644 index 000000000..fde3b2188 --- /dev/null +++ b/test/core/opt_view00.v3 @@ -0,0 +1,6 @@ +//@execute 0=0; 1=1; 256=1; 65537=2; 16909060=10 +def main(x: int) -> int { + def u = u8.view; + var a = u(x >> 0), b = u(x >> 8), c = u(x >> 16), d = u(x >> 24); + return a + b + c + d; +}