load-store-aggregate.ll 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. ; This testcase shows that scalarrepl is able to replace struct alloca's which
  2. ; are directly loaded from or stored to (using the first class aggregates
  3. ; feature).
  4. target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
  5. ; RUN: opt < %s -scalarrepl -S > %t
  6. ; RUN: cat %t | not grep alloca
  7. %struct.foo = type { i32, i32 }
  8. define i32 @test(%struct.foo* %P) {
  9. entry:
  10. %L = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2]
  11. %V = load %struct.foo, %struct.foo* %P
  12. store %struct.foo %V, %struct.foo* %L
  13. %tmp4 = getelementptr %struct.foo, %struct.foo* %L, i32 0, i32 0 ; <i32*> [#uses=1]
  14. %tmp5 = load i32, i32* %tmp4 ; <i32> [#uses=1]
  15. ret i32 %tmp5
  16. }
  17. define %struct.foo @test2(i32 %A, i32 %B) {
  18. entry:
  19. %L = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2]
  20. %L.0 = getelementptr %struct.foo, %struct.foo* %L, i32 0, i32 0
  21. store i32 %A, i32* %L.0
  22. %L.1 = getelementptr %struct.foo, %struct.foo* %L, i32 0, i32 1
  23. store i32 %B, i32* %L.1
  24. %V = load %struct.foo, %struct.foo* %L
  25. ret %struct.foo %V
  26. }