futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | None
Language | GHC2021

Futhark.Optimise.CSE

Description

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 :: (AliasableRep rep, CSEInOp (Op (Aliases rep))) => Bool -> Pass rep rep
- performCSEOnFunDef :: (AliasableRep rep, CSEInOp (Op (Aliases rep))) => Bool -> FunDef rep -> FunDef rep
- performCSEOnStms :: (AliasableRep rep, CSEInOp (Op (Aliases rep))) => Stms rep -> Stms rep
- class CSEInOp op

# Documentation

performCSE :: (AliasableRep rep, CSEInOp (Op (Aliases 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 :: (AliasableRep rep, CSEInOp (Op (Aliases 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 :: (AliasableRep rep, CSEInOp (Op (Aliases rep))) => Stms rep -> Stms rep Source #

Perform CSE on some statements.

class CSEInOp op Source #

The operations that permit CSE.

Minimal complete definition

cseInOp

#### Instances

Instances details

(AliasableRep rep, CSEInOp (Op (Aliases rep))) => CSEInOp (SOAC (Aliases rep)) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: SOAC (Aliases rep) -> CSEM rep0 (SOAC (Aliases rep))
(Aliased rep, CSEInOp (Op rep), CSEInOp (op rep)) => CSEInOp (HostOp op rep) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: HostOp op rep -> CSEM rep0 (HostOp op rep)
(Aliased rep, CSEInOp (Op rep), CSEInOp (op rep)) => CSEInOp (MCOp op rep) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: MCOp op rep -> CSEM rep0 (MCOp op rep)
CSEInOp (op rep) => CSEInOp (MemOp op rep) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: MemOp op rep -> CSEM rep0 (MemOp op rep)
CSEInOp (NoOp rep) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: NoOp rep -> CSEM rep0 (NoOp rep)
(Aliased rep, CSEInOp (Op rep)) => CSEInOp (SegOp lvl rep) Source # |
Instance details Defined in Futhark.Optimise.CSE Methods cseInOp :: SegOp lvl rep -> CSEM rep0 (SegOp lvl rep)