Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module implements common-subexpression elimination. This module does not actually remove the duplicate, but only replaces one with a diference to the other. E.g:
let a = x + y let b = x + y
becomes:
let a = x + y let b = a
After which copy propagation in the simplifier will actually remove
the definition of b
.
Our CSE is still rather stupid. No normalisation is performed, so
the expressions x+y
and y+x
will be considered distinct.
Furthermore, no expression with its own binding will be considered
equal to any other, since the variable names will be distinct.
This affects SOACs in particular.
Synopsis
- performCSE :: (ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => Bool -> Pass rep rep
- performCSEOnFunDef :: (ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => Bool -> FunDef rep -> FunDef rep
- performCSEOnStms :: (ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => Bool -> Stms rep -> Stms rep
- class CSEInOp op
Documentation
performCSE :: (ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => Bool -> Pass rep rep Source #
Perform CSE on every function in a program.
If the boolean argument is false, the pass will not perform CSE on expressions producing arrays. This should be disabled when the rep has memory information, since at that point arrays have identity beyond their value.
performCSEOnFunDef :: (ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => Bool -> FunDef rep -> FunDef rep Source #
Perform CSE on a single function.
If the boolean argument is false, the pass will not perform CSE on expressions producing arrays. This should be disabled when the rep has memory information, since at that point arrays have identity beyond their value.
performCSEOnStms :: (ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => Bool -> Stms rep -> Stms rep Source #
Perform CSE on some statements.
If the boolean argument is false, the pass will not perform CSE on expressions producing arrays. This should be disabled when the rep has memory information, since at that point arrays have identity beyond their value.
The operations that permit CSE.
cseInOp
Instances
CSEInOp () Source # | |
Defined in Futhark.Optimise.CSE cseInOp :: () -> CSEM rep () | |
(ASTRep rep, CanBeAliased (Op rep), CSEInOp (OpWithAliases (Op rep))) => CSEInOp (SOAC (Aliases rep)) Source # | |
CSEInOp op => CSEInOp (MemOp op) Source # | |
Defined in Futhark.Optimise.CSE | |
(ASTRep rep, Aliased rep, CSEInOp (Op rep)) => CSEInOp (SegOp lvl rep) Source # | |
Defined in Futhark.Optimise.CSE | |
(ASTRep rep, Aliased rep, CSEInOp (Op rep), CSEInOp op) => CSEInOp (MCOp rep op) Source # | |
Defined in Futhark.Optimise.CSE | |
(ASTRep rep, Aliased rep, CSEInOp (Op rep), CSEInOp op) => CSEInOp (HostOp rep op) Source # | |
Defined in Futhark.Optimise.CSE |