Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Munksgaard/edc882b0d19716d9370bb11fabb80b0f to your computer and use it in GitHub Desktop.
Save Munksgaard/edc882b0d19716d9370bb11fabb80b0f to your computer and use it in GitHub Desktop.
-- A simple test for index-function generalization across a for loop
-- ==
-- input { [0, 1000, 42, 1001, 50000] }
-- output { 52043i32 }
-- structure gpu { Copy 0 }
let main [n] (a: [n]i32): i32 =
let b = loop xs = a[1:] for i < n / 2 - 2 do
xs[i:] -- This will result in a copy, but it needn't
in reduce (+) 0 b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment