uglygep-address-space.ll 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ; RUN: opt < %s -loop-reduce -S | FileCheck %s
  2. ; LSR shouldn't consider %t8 to be an interesting user of %t6, and it
  3. ; should be able to form pretty GEPs.
  4. target datalayout = "e-p:64:64:64-p1:16:16:16-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"
  5. ; Copy of uglygep with a different address space
  6. ; This tests expandAddToGEP uses the right smaller integer type for
  7. ; another address space
  8. define void @Z4() nounwind {
  9. ; CHECK: define void @Z4
  10. bb:
  11. br label %bb3
  12. bb1: ; preds = %bb3
  13. br i1 undef, label %bb10, label %bb2
  14. bb2: ; preds = %bb1
  15. %t = add i16 %t4, 1 ; <i16> [#uses=1]
  16. br label %bb3
  17. bb3: ; preds = %bb2, %bb
  18. %t4 = phi i16 [ %t, %bb2 ], [ 0, %bb ] ; <i16> [#uses=3]
  19. br label %bb1
  20. ; CHECK: bb10:
  21. ; CHECK-NEXT: %t7 = icmp eq i16 %t4, 0
  22. ; Host %t2 computation outside the loop.
  23. ; CHECK-NEXT: [[SCEVGEP:%[^ ]+]] = getelementptr i8, i8 addrspace(1)* undef, i16 %t4
  24. ; CHECK-NEXT: br label %bb14
  25. bb10: ; preds = %bb9
  26. %t7 = icmp eq i16 %t4, 0 ; <i1> [#uses=1]
  27. %t3 = add i16 %t4, 16 ; <i16> [#uses=1]
  28. br label %bb14
  29. ; CHECK: bb14:
  30. ; CHECK-NEXT: store i8 undef, i8 addrspace(1)* [[SCEVGEP]]
  31. ; CHECK-NEXT: %t6 = load float addrspace(1)*, float addrspace(1)* addrspace(1)* undef
  32. ; Fold %t3's add within the address.
  33. ; CHECK-NEXT: [[SCEVGEP1:%[^ ]+]] = getelementptr float, float addrspace(1)* %t6, i16 4
  34. ; CHECK-NEXT: [[SCEVGEP2:%[^ ]+]] = bitcast float addrspace(1)* [[SCEVGEP1]] to i8 addrspace(1)*
  35. ; Use the induction variable (%t4) to access the right element
  36. ; CHECK-NEXT: [[ADDRESS:%[^ ]+]] = getelementptr i8, i8 addrspace(1)* [[SCEVGEP2]], i16 %t4
  37. ; CHECK-NEXT: store i8 undef, i8 addrspace(1)* [[ADDRESS]]
  38. ; CHECK-NEXT: br label %bb14
  39. bb14: ; preds = %bb14, %bb10
  40. %t2 = getelementptr inbounds i8, i8 addrspace(1)* undef, i16 %t4 ; <i8*> [#uses=1]
  41. store i8 undef, i8 addrspace(1)* %t2
  42. %t6 = load float addrspace(1)*, float addrspace(1)* addrspace(1)* undef
  43. %t8 = bitcast float addrspace(1)* %t6 to i8 addrspace(1)* ; <i8*> [#uses=1]
  44. %t9 = getelementptr inbounds i8, i8 addrspace(1)* %t8, i16 %t3 ; <i8*> [#uses=1]
  45. store i8 undef, i8 addrspace(1)* %t9
  46. br label %bb14
  47. }