Skip to content

Commit

Permalink
Consider sel cheap for inlining in Expand.
Browse files Browse the repository at this point in the history
  • Loading branch information
kffaxen authored and pjonsson committed Mar 17, 2021
1 parent 6f03cdd commit a55d3c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Feldspar/Core/Middleend/Expand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,11 @@ ixAndInv ai v vs = go ai

-- | Check that an expression is a simple array reference that we can inline
simpleArrRef :: UExp -> Bool
simpleArrRef (In _ (App GetIx _ [In _ (Variable _), e])) = simpleIdxE e
simpleArrRef (In _ (App GetIx _ [a, e])) = simpleArrE a && simpleIdxE e
where simpleIdxE (In _ (Variable _)) = True
simpleIdxE (In _ (App op _ es)) = op `elem` [Add,Sub,Mul] && all simpleIdxE es
simpleIdxE _ = False
simpleArrE (In _ (Variable _)) = True
simpleArrE (In _ (App (Sel _) _ [In _ (Variable _)])) = True
simpleArrE _ = False
simpleArrRef _ = False

0 comments on commit a55d3c0

Please sign in to comment.