# HG changeset patch # User vnorilo # Date 1669812692 -7200 # Wed Nov 30 14:51:32 2022 +0200 # Branch dev # Node ID 56ce1a16920380f59904de3495a838f2b8dd89cd # Parent bb3b2eb0b087f28600052ee2b83cfad0b6a12b9e Fix some problematic optimizations on select, GCC compatibility diff --git a/src/common/DynamicScope.h b/src/common/DynamicScope.h --- a/src/common/DynamicScope.h +++ b/src/common/DynamicScope.h @@ -2,6 +2,7 @@ #include #include +#include std::unordered_map* __dynscp_tls(); void __dynscp_tls_dtor(void *key); diff --git a/src/k3/FlowControl.cpp b/src/k3/FlowControl.cpp --- a/src/k3/FlowControl.cpp +++ b/src/k3/FlowControl.cpp @@ -5,6 +5,7 @@ #include "TypeAlgebra.h" #include "Native.h" #include "Conversions.h" +#include "Reactive.h" #include "Invariant.h" namespace K3 { @@ -152,7 +153,9 @@ v = v.First(); vg = vg->GraphFirst(); } - + + vg = ReactiveOperators::Impose::New(A0.node, vg); + return Specialization(vg, v); } else { t.GetRep().Diagnostic(LogErrors, this, Error::TypeMismatchInSpecialization, A0.result, "Select can accept a constant index"); @@ -226,14 +229,17 @@ CTRef AtIndex::New(Type vectorTy, CTRef vector, CTRef index) { Native::Constant *c; - if (index->Cast(c)) { + // constant propagation breaks reactive clock; disabled below + if (false && index->Cast(c)) { assert(c->FixedResult().IsInt32()); int i = *(std::int32_t*)c->GetPointer(); auto svTy = vectorTy; + while (i--) { vector = vector->GraphRest(); svTy = svTy.Rest(); } + // handle possible nil termination if (svTy == vectorTy.First()) return vector; else { @@ -469,4 +475,4 @@ Modulo(idx,lenc),lenc),"vector index", "Selects an element from the table according to index, using modulo addressing to wrap around the index"); } -}; \ No newline at end of file +};