Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Imperfect dead code elimination #473

Open
tomsmeding opened this issue Oct 12, 2020 · 0 comments
Open

[BUG] Imperfect dead code elimination #473

tomsmeding opened this issue Oct 12, 2020 · 0 comments

Comments

@tomsmeding
Copy link
Member

tomsmeding commented Oct 12, 2020

Description
For certain contrived inputs, fusion leaves unused program fragments in the output AST. It seems this can happen when a node was originally used, but due to expression simplification / fusion became unused.

Steps to reproduce
Print the following using show with Data.Array.Accelerate imported unqualified (and Prelude not imported)::

let arr = use (fromList Z [1 :: Float])
in zipWith
     (\x _ -> x)
     (generate Z_ (\_ -> 1 :: Exp Float))
     (zipWith (\x y -> T2 x y)
              (map (\x -> x) arr)
              (map (\x -> x) arr))

The result is:

let
  a0 = use (Scalar Z [1.0])
  a1 = map (\x0 -> x0) a0
  a2 = map (\x0 -> x0) a0
in
generate () (\() -> 1.0)

Note that none of a0, a1 and a2 are actually used.

Expected behaviour
The output was expected to be generate () (\() -> 1.0). :)

Your environment

  • Accelerate: 1.3.0.0; also 203a9271
  • Accelerate backend(s): n/a
  • GHC: 8.8.4
  • OS: Arch Linux

Additional context
AD again delivers in producing obscure code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant