gep.ll 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ; RUN: opt < %s -basicaa -slp-vectorizer -S |FileCheck %s
  2. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  3. target triple = "x86_64-unknown-unknown"
  4. ; Test if SLP can handle GEP expressions.
  5. ; The test perform the following action:
  6. ; x->first = y->first + 16
  7. ; x->second = y->second + 16
  8. ; CHECK-LABEL: foo1
  9. ; CHECK: <2 x i32*>
  10. define void @foo1 ({ i32*, i32* }* noalias %x, { i32*, i32* }* noalias %y) {
  11. %1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 0
  12. %2 = load i32*, i32** %1, align 8
  13. %3 = getelementptr inbounds i32, i32* %2, i64 16
  14. %4 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 0
  15. store i32* %3, i32** %4, align 8
  16. %5 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 1
  17. %6 = load i32*, i32** %5, align 8
  18. %7 = getelementptr inbounds i32, i32* %6, i64 16
  19. %8 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 1
  20. store i32* %7, i32** %8, align 8
  21. ret void
  22. }
  23. ; Test that we don't vectorize GEP expressions if indexes are not constants.
  24. ; We can't produce an efficient code in that case.
  25. ; CHECK-LABEL: foo2
  26. ; CHECK-NOT: <2 x i32*>
  27. define void @foo2 ({ i32*, i32* }* noalias %x, { i32*, i32* }* noalias %y, i32 %i) {
  28. %1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 0
  29. %2 = load i32*, i32** %1, align 8
  30. %3 = getelementptr inbounds i32, i32* %2, i32 %i
  31. %4 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 0
  32. store i32* %3, i32** %4, align 8
  33. %5 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 1
  34. %6 = load i32*, i32** %5, align 8
  35. %7 = getelementptr inbounds i32, i32* %6, i32 %i
  36. %8 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 1
  37. store i32* %7, i32** %8, align 8
  38. ret void
  39. }