saxpy.ll 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
  2. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  3. target triple = "x86_64-apple-macosx10.8.0"
  4. ; SLP vectorization example from http://cs.stanford.edu/people/eschkufz/research/asplos291-schkufza.pdf
  5. ;CHECK: SAXPY
  6. ;CHECK: mul nsw <4 x i32>
  7. ;CHECK: ret
  8. define void @SAXPY(i32* noalias nocapture %x, i32* noalias nocapture %y, i32 %a, i64 %i) {
  9. %1 = getelementptr inbounds i32, i32* %x, i64 %i
  10. %2 = load i32, i32* %1, align 4
  11. %3 = mul nsw i32 %2, %a
  12. %4 = getelementptr inbounds i32, i32* %y, i64 %i
  13. %5 = load i32, i32* %4, align 4
  14. %6 = add nsw i32 %3, %5
  15. store i32 %6, i32* %1, align 4
  16. %7 = add i64 %i, 1
  17. %8 = getelementptr inbounds i32, i32* %x, i64 %7
  18. %9 = load i32, i32* %8, align 4
  19. %10 = mul nsw i32 %9, %a
  20. %11 = getelementptr inbounds i32, i32* %y, i64 %7
  21. %12 = load i32, i32* %11, align 4
  22. %13 = add nsw i32 %10, %12
  23. store i32 %13, i32* %8, align 4
  24. %14 = add i64 %i, 2
  25. %15 = getelementptr inbounds i32, i32* %x, i64 %14
  26. %16 = load i32, i32* %15, align 4
  27. %17 = mul nsw i32 %16, %a
  28. %18 = getelementptr inbounds i32, i32* %y, i64 %14
  29. %19 = load i32, i32* %18, align 4
  30. %20 = add nsw i32 %17, %19
  31. store i32 %20, i32* %15, align 4
  32. %21 = add i64 %i, 3
  33. %22 = getelementptr inbounds i32, i32* %x, i64 %21
  34. %23 = load i32, i32* %22, align 4
  35. %24 = mul nsw i32 %23, %a
  36. %25 = getelementptr inbounds i32, i32* %y, i64 %21
  37. %26 = load i32, i32* %25, align 4
  38. %27 = add nsw i32 %24, %26
  39. store i32 %27, i32* %22, align 4
  40. ret void
  41. }
  42. ; Make sure we don't crash on this one.
  43. define void @SAXPY_crash(i32* noalias nocapture %x, i32* noalias nocapture %y, i64 %i) {
  44. %1 = add i64 %i, 1
  45. %2 = getelementptr inbounds i32, i32* %x, i64 %1
  46. %3 = getelementptr inbounds i32, i32* %y, i64 %1
  47. %4 = load i32, i32* %3, align 4
  48. %5 = add nsw i32 undef, %4
  49. store i32 %5, i32* %2, align 4
  50. %6 = add i64 %i, 2
  51. %7 = getelementptr inbounds i32, i32* %x, i64 %6
  52. %8 = getelementptr inbounds i32, i32* %y, i64 %6
  53. %9 = load i32, i32* %8, align 4
  54. %10 = add nsw i32 undef, %9
  55. store i32 %10, i32* %7, align 4
  56. ret void
  57. }