base: io_writer.limited_etc_fast now needs len>=1

This commit is contained in:
Nigel Tao committed 2023-11-25 10:50:02 +11:00
1 parent dc269f3f54
commit 8de7f559e0
7 files changed
+43

No files matched your search

+4
View File
@@ -576,6 +576,7 @@ var funcsOther = [...]string{
"io_writer.limited_copy_u32_from_slice!(up_to: u32, s: roslice u8) u32",
// TODO: this should have explicit pre-conditions:
// - up_to >= 1
// - up_to <= this.length()
// - distance >= 1
// - distance <= this.history_length()
@@ -583,6 +584,7 @@ var funcsOther = [...]string{
"io_writer.limited_copy_u32_from_history_fast!(up_to: u32, distance: u32) u32",
// TODO: this should have explicit pre-conditions:
// - up_to >= 1
// - up_to <= this.length()
// - distance >= 1
// - distance <= this.history_length()
@@ -590,6 +592,7 @@ var funcsOther = [...]string{
"io_writer.limited_copy_u32_from_history_fast_return_cusp!(up_to: u32, distance: u32) u32[..= 0xFFFF]",
// TODO: this should have explicit pre-conditions:
// - up_to >= 1
// - (up_to + 8) <= this.length()
// - distance >= 8
// - distance <= this.history_length()
@@ -597,6 +600,7 @@ var funcsOther = [...]string{
"io_writer.limited_copy_u32_from_history_8_byte_chunks_fast!(up_to: u32, distance: u32) u32",
// TODO: this should have explicit pre-conditions:
// - up_to >= 1
// - (up_to + 8) <= this.length()
// - distance == 1
// - distance <= this.history_length()
+19
View File
@@ -1337,6 +1337,7 @@ func (q *checker) canUndoByte(recv *a.Expr) error {
func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node, adj *big.Int, minDistance *big.Int, exactDistance *big.Int) error {
// As per cgen's io-private.h, there are three pre-conditions:
// - upTo >= one
// - (upTo + adj) <= this.length()
// - either (distance >= minDistance) or (distance == exactDistance),
// depending on which of minDistance and exactDistance is non-nil.
@@ -1350,6 +1351,24 @@ func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node,
upTo := args[0].AsArg().Value()
distance := args[1].AsArg().Value()
// Check "upto >= one".
check9: // TODO: renumber.
for {
for _, x := range q.facts {
if x.Operator() != t.IDXBinaryGreaterEq {
continue
}
if lhs := x.LHS().AsExpr(); !lhs.Eq(upTo) {
continue
}
if rcv := x.RHS().AsExpr().ConstValue(); (rcv == nil) || (rcv.Sign() <= 0) {
continue
}
break check9
}
return fmt.Errorf("check: could not prove %s >= 1", upTo.Str(q.tm))
}
// Check "upTo <= this.length()".
check0:
for {