From 502afe1424b0f4addb4d018137a2d183a5e34dc8 Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Tue, 7 Jan 2025 13:25:39 +0000 Subject: [PATCH] Compute 2^constant at compile-time --- brat/Brat/Checker/Helpers.hs | 9 ++------- brat/test/Test/Compile/Hugr.hs | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/brat/Brat/Checker/Helpers.hs b/brat/Brat/Checker/Helpers.hs index 48e3268b..07bd3e3c 100644 --- a/brat/Brat/Checker/Helpers.hs +++ b/brat/Brat/Checker/Helpers.hs @@ -481,13 +481,8 @@ buildNatVal nv@(NumValue n gro) = case n of buildSM :: StrictMono (VVar Z) -> Checking Src buildSM (StrictMono k mono) = do - -- Calculate 2^k as `factor` - two <- buildNum 2 - kDangling <- buildNum k - ((lhs,rhs),factor) <- buildArithOp Pow - req $ Wire (end two, TNat, end lhs) - req $ Wire (end kDangling, TNat, end rhs) - -- Multiply mono by 2^k + factor <- buildNum $ 2 ^ k + -- Multiply mono by 2^k; note we could avoid this if k==0 ((lhs,rhs),out) <- buildArithOp Mul monoDangling <- buildMono mono req $ Wire (end factor, TNat, end lhs) diff --git a/brat/test/Test/Compile/Hugr.hs b/brat/test/Test/Compile/Hugr.hs index ef24aa26..11de7093 100644 --- a/brat/test/Test/Compile/Hugr.hs +++ b/brat/test/Test/Compile/Hugr.hs @@ -38,7 +38,6 @@ nonCompilingExamples = expectedCheckingFails ++ expectedParsingFails ++ ,"fanout" -- Contains Selectors ,"vectorise" -- Generates MapFun nodes which aren't implemented yet ,"batcher-merge-sort" -- Generates MapFun nodes which aren't implemented yet - ,"infer" -- Generates `Pow` nodes which aren't implemented yet -- Victims of #13 ,"arith" ,"cqcconf"