align.ll 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ; RUN: opt -inline -preserve-alignment-assumptions-during-inlining -S < %s | 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-unknown-linux-gnu"
  4. define void @hello(float* align 128 nocapture %a, float* nocapture readonly %c) #0 {
  5. entry:
  6. %0 = load float, float* %c, align 4
  7. %arrayidx = getelementptr inbounds float, float* %a, i64 5
  8. store float %0, float* %arrayidx, align 4
  9. ret void
  10. }
  11. define void @foo(float* nocapture %a, float* nocapture readonly %c) #0 {
  12. entry:
  13. tail call void @hello(float* %a, float* %c)
  14. %0 = load float, float* %c, align 4
  15. %arrayidx = getelementptr inbounds float, float* %a, i64 7
  16. store float %0, float* %arrayidx, align 4
  17. ret void
  18. }
  19. ; CHECK: define void @foo(float* nocapture %a, float* nocapture readonly %c) #0 {
  20. ; CHECK: entry:
  21. ; CHECK: %ptrint = ptrtoint float* %a to i64
  22. ; CHECK: %maskedptr = and i64 %ptrint, 127
  23. ; CHECK: %maskcond = icmp eq i64 %maskedptr, 0
  24. ; CHECK: call void @llvm.assume(i1 %maskcond)
  25. ; CHECK: %0 = load float, float* %c, align 4
  26. ; CHECK: %arrayidx.i = getelementptr inbounds float, float* %a, i64 5
  27. ; CHECK: store float %0, float* %arrayidx.i, align 4
  28. ; CHECK: %1 = load float, float* %c, align 4
  29. ; CHECK: %arrayidx = getelementptr inbounds float, float* %a, i64 7
  30. ; CHECK: store float %1, float* %arrayidx, align 4
  31. ; CHECK: ret void
  32. ; CHECK: }
  33. define void @fooa(float* nocapture align 128 %a, float* nocapture readonly %c) #0 {
  34. entry:
  35. tail call void @hello(float* %a, float* %c)
  36. %0 = load float, float* %c, align 4
  37. %arrayidx = getelementptr inbounds float, float* %a, i64 7
  38. store float %0, float* %arrayidx, align 4
  39. ret void
  40. }
  41. ; CHECK: define void @fooa(float* nocapture align 128 %a, float* nocapture readonly %c) #0 {
  42. ; CHECK: entry:
  43. ; CHECK: %0 = load float, float* %c, align 4
  44. ; CHECK: %arrayidx.i = getelementptr inbounds float, float* %a, i64 5
  45. ; CHECK: store float %0, float* %arrayidx.i, align 4
  46. ; CHECK: %1 = load float, float* %c, align 4
  47. ; CHECK: %arrayidx = getelementptr inbounds float, float* %a, i64 7
  48. ; CHECK: store float %1, float* %arrayidx, align 4
  49. ; CHECK: ret void
  50. ; CHECK: }
  51. define void @hello2(float* align 128 nocapture %a, float* align 128 nocapture %b, float* nocapture readonly %c) #0 {
  52. entry:
  53. %0 = load float, float* %c, align 4
  54. %arrayidx = getelementptr inbounds float, float* %a, i64 5
  55. store float %0, float* %arrayidx, align 4
  56. %arrayidx1 = getelementptr inbounds float, float* %b, i64 8
  57. store float %0, float* %arrayidx1, align 4
  58. ret void
  59. }
  60. define void @foo2(float* nocapture %a, float* nocapture %b, float* nocapture readonly %c) #0 {
  61. entry:
  62. tail call void @hello2(float* %a, float* %b, float* %c)
  63. %0 = load float, float* %c, align 4
  64. %arrayidx = getelementptr inbounds float, float* %a, i64 7
  65. store float %0, float* %arrayidx, align 4
  66. ret void
  67. }
  68. ; CHECK: define void @foo2(float* nocapture %a, float* nocapture %b, float* nocapture readonly %c) #0 {
  69. ; CHECK: entry:
  70. ; CHECK: %ptrint = ptrtoint float* %a to i64
  71. ; CHECK: %maskedptr = and i64 %ptrint, 127
  72. ; CHECK: %maskcond = icmp eq i64 %maskedptr, 0
  73. ; CHECK: call void @llvm.assume(i1 %maskcond)
  74. ; CHECK: %ptrint1 = ptrtoint float* %b to i64
  75. ; CHECK: %maskedptr2 = and i64 %ptrint1, 127
  76. ; CHECK: %maskcond3 = icmp eq i64 %maskedptr2, 0
  77. ; CHECK: call void @llvm.assume(i1 %maskcond3)
  78. ; CHECK: %0 = load float, float* %c, align 4
  79. ; CHECK: %arrayidx.i = getelementptr inbounds float, float* %a, i64 5
  80. ; CHECK: store float %0, float* %arrayidx.i, align 4
  81. ; CHECK: %arrayidx1.i = getelementptr inbounds float, float* %b, i64 8
  82. ; CHECK: store float %0, float* %arrayidx1.i, align 4
  83. ; CHECK: %1 = load float, float* %c, align 4
  84. ; CHECK: %arrayidx = getelementptr inbounds float, float* %a, i64 7
  85. ; CHECK: store float %1, float* %arrayidx, align 4
  86. ; CHECK: ret void
  87. ; CHECK: }
  88. attributes #0 = { nounwind uwtable }