accelerate icon indicating copy to clipboard operation
accelerate copied to clipboard

[BUG] Imperfect dead code elimination

Open tomsmeding opened this issue 5 years ago • 0 comments

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 :)

tomsmeding avatar Oct 12 '20 19:10 tomsmeding