mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
Unroll iterate loops.
name old speed new speed delta puffs_adler32_10k/clang 2.12GB/s ± 1% 2.42GB/s ± 1% +14.24% (p=0.008 n=5+5) puffs_adler32_100k/clang 2.12GB/s ± 3% 2.43GB/s ± 0% +14.29% (p=0.008 n=5+5) mimic_adler32_10k/clang 2.93GB/s ± 2% 2.96GB/s ± 0% ~ (p=0.310 n=5+5) mimic_adler32_100k/clang 2.89GB/s ± 2% 2.91GB/s ± 0% ~ (p=1.000 n=5+5) puffs_adler32_10k/gcc 2.17GB/s ± 1% 3.23GB/s ± 0% +48.59% (p=0.008 n=5+5) puffs_adler32_100k/gcc 2.18GB/s ± 1% 3.23GB/s ± 0% +48.34% (p=0.008 n=5+5) mimic_adler32_10k/gcc 2.97GB/s ± 0% 2.96GB/s ± 1% ~ (p=1.000 n=5+5) mimic_adler32_100k/gcc 2.91GB/s ± 1% 2.91GB/s ± 1% ~ (p=0.548 n=5+5)
This commit is contained in:
1 parent
b024cb1d8c
commit
245e3ec7b9
6 files changed
+94
-19
No files matched your search
+14
-10
@@ -393,7 +393,7 @@ func NewField(name t.ID, xType *TypeExpr, defaultValue *Expr) *Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate is "iterate:ID1 (vars), List1 { List2 }":
|
||||
// Iterate is "iterate.LHS:ID1 (vars), List1 { List2 }":
|
||||
// - FlagsHasBreak is the iterate has an explicit break
|
||||
// - FlagsHasContinue is the iterate has an explicit continue
|
||||
// - ID1: <0|label>
|
||||
@@ -406,6 +406,7 @@ func (n *Iterate) Node() *Node { return (*Node)(n) }
|
||||
func (n *Iterate) HasBreak() bool { return n.flags&FlagsHasBreak != 0 }
|
||||
func (n *Iterate) HasContinue() bool { return n.flags&FlagsHasContinue != 0 }
|
||||
func (n *Iterate) Label() t.ID { return n.id1 }
|
||||
func (n *Iterate) UnrollCount() *Expr { return n.lhs.Expr() }
|
||||
func (n *Iterate) Variables() []*Node { return n.list0 }
|
||||
func (n *Iterate) Asserts() []*Node { return n.list1 }
|
||||
func (n *Iterate) Body() []*Node { return n.list2 }
|
||||
@@ -413,30 +414,33 @@ func (n *Iterate) Body() []*Node { return n.list2 }
|
||||
func (n *Iterate) SetHasBreak() { n.flags |= FlagsHasBreak }
|
||||
func (n *Iterate) SetHasContinue() { n.flags |= FlagsHasContinue }
|
||||
|
||||
func NewIterate(label t.ID, variables []*Node, asserts []*Node, body []*Node) *Iterate {
|
||||
func NewIterate(label t.ID, unrollCount *Expr, variables []*Node, asserts []*Node, body []*Node) *Iterate {
|
||||
return &Iterate{
|
||||
kind: KIterate,
|
||||
id1: label,
|
||||
lhs: unrollCount.Node(),
|
||||
list0: variables,
|
||||
list1: asserts,
|
||||
list2: body,
|
||||
}
|
||||
}
|
||||
|
||||
// While is "while:ID1 LHS, List1 { List2 }":
|
||||
// While is "while:ID1 MHS, List1 { List2 }":
|
||||
// - FlagsHasBreak is the while has an explicit break
|
||||
// - FlagsHasContinue is the while has an explicit continue
|
||||
// - ID1: <0|label>
|
||||
// - LHS: <Expr>
|
||||
// - MHS: <Expr>
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> loop body
|
||||
//
|
||||
// TODO: should we be able to unroll while loops too?
|
||||
type While Node
|
||||
|
||||
func (n *While) Node() *Node { return (*Node)(n) }
|
||||
func (n *While) HasBreak() bool { return n.flags&FlagsHasBreak != 0 }
|
||||
func (n *While) HasContinue() bool { return n.flags&FlagsHasContinue != 0 }
|
||||
func (n *While) Label() t.ID { return n.id1 }
|
||||
func (n *While) Condition() *Expr { return n.lhs.Expr() }
|
||||
func (n *While) Condition() *Expr { return n.mhs.Expr() }
|
||||
func (n *While) Asserts() []*Node { return n.list1 }
|
||||
func (n *While) Body() []*Node { return n.list2 }
|
||||
|
||||
@@ -447,21 +451,21 @@ func NewWhile(label t.ID, condition *Expr, asserts []*Node, body []*Node) *While
|
||||
return &While{
|
||||
kind: KWhile,
|
||||
id1: label,
|
||||
lhs: condition.Node(),
|
||||
mhs: condition.Node(),
|
||||
list1: asserts,
|
||||
list2: body,
|
||||
}
|
||||
}
|
||||
|
||||
// If is "if LHS { List0 } else RHS" or "if LHS { List0 } else { List1 }":
|
||||
// - LHS: <Expr>
|
||||
// If is "if MHS { List0 } else RHS" or "if MHS { List0 } else { List1 }":
|
||||
// - MHS: <Expr>
|
||||
// - RHS: <nil|If>
|
||||
// - List0: <Statement> if-true body
|
||||
// - List1: <Statement> if-false body
|
||||
type If Node
|
||||
|
||||
func (n *If) Node() *Node { return (*Node)(n) }
|
||||
func (n *If) Condition() *Expr { return n.lhs.Expr() }
|
||||
func (n *If) Condition() *Expr { return n.mhs.Expr() }
|
||||
func (n *If) ElseIf() *If { return n.rhs.If() }
|
||||
func (n *If) BodyIfTrue() []*Node { return n.list0 }
|
||||
func (n *If) BodyIfFalse() []*Node { return n.list1 }
|
||||
@@ -469,7 +473,7 @@ func (n *If) BodyIfFalse() []*Node { return n.list1 }
|
||||
func NewIf(condition *Expr, elseIf *If, bodyIfTrue []*Node, bodyIfFalse []*Node) *If {
|
||||
return &If{
|
||||
kind: KIf,
|
||||
lhs: condition.Node(),
|
||||
mhs: condition.Node(),
|
||||
rhs: elseIf.Node(),
|
||||
list0: bodyIfTrue,
|
||||
list1: bodyIfFalse,
|
||||
|
||||
Reference in new issue
Block a user