ada-loops.ll 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ; RUN: opt < %s -indvars -S | FileCheck %s
  2. ;
  3. ; PR1301
  4. ; Do a bunch of analysis and prove that the loops can use an i32 trip
  5. ; count without casting.
  6. ;
  7. ; Note that all four functions should actually be converted to
  8. ; memset. However, this test case validates indvars behavior. We
  9. ; don't check that phis are "folded together" because that is a job
  10. ; for loop strength reduction. But indvars must remove sext, zext, and add i8.
  11. ;
  12. ; CHECK-NOT: {{sext|zext|add i8}}
  13. ; ModuleID = 'ada.bc'
  14. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32"
  15. target triple = "i686-pc-linux-gnu"
  16. define void @kinds__sbytezero([256 x i32]* nocapture %a) nounwind {
  17. bb.thread:
  18. %tmp46 = getelementptr [256 x i32], [256 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
  19. store i32 0, i32* %tmp46
  20. br label %bb
  21. bb: ; preds = %bb, %bb.thread
  22. %i.0.reg2mem.0 = phi i8 [ -128, %bb.thread ], [ %tmp8, %bb ] ; <i8> [#uses=1]
  23. %tmp8 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=3]
  24. %tmp1 = sext i8 %tmp8 to i32 ; <i32> [#uses=1]
  25. %tmp3 = add i32 %tmp1, 128 ; <i32> [#uses=1]
  26. %tmp4 = getelementptr [256 x i32], [256 x i32]* %a, i32 0, i32 %tmp3 ; <i32*> [#uses=1]
  27. store i32 0, i32* %tmp4
  28. %0 = icmp eq i8 %tmp8, 127 ; <i1> [#uses=1]
  29. br i1 %0, label %return, label %bb
  30. return: ; preds = %bb
  31. ret void
  32. }
  33. define void @kinds__ubytezero([256 x i32]* nocapture %a) nounwind {
  34. bb.thread:
  35. %tmp35 = getelementptr [256 x i32], [256 x i32]* %a, i32 0, i32 0 ; <i32*> [#uses=1]
  36. store i32 0, i32* %tmp35
  37. br label %bb
  38. bb: ; preds = %bb, %bb.thread
  39. %i.0.reg2mem.0 = phi i8 [ 0, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=1]
  40. %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=3]
  41. %tmp1 = zext i8 %tmp7 to i32 ; <i32> [#uses=1]
  42. %tmp3 = getelementptr [256 x i32], [256 x i32]* %a, i32 0, i32 %tmp1 ; <i32*> [#uses=1]
  43. store i32 0, i32* %tmp3
  44. %0 = icmp eq i8 %tmp7, -1 ; <i1> [#uses=1]
  45. br i1 %0, label %return, label %bb
  46. return: ; preds = %bb
  47. ret void
  48. }
  49. define void @kinds__srangezero([21 x i32]* nocapture %a) nounwind {
  50. bb.thread:
  51. br label %bb
  52. bb: ; preds = %bb, %bb.thread
  53. %i.0.reg2mem.0 = phi i8 [ -10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2]
  54. %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1]
  55. %tmp4 = add i32 %tmp12, 10 ; <i32> [#uses=1]
  56. %tmp5 = getelementptr [21 x i32], [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1]
  57. store i32 0, i32* %tmp5
  58. %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2]
  59. %0 = icmp sgt i8 %tmp7, 10 ; <i1> [#uses=1]
  60. br i1 %0, label %return, label %bb
  61. return: ; preds = %bb
  62. ret void
  63. }
  64. define void @kinds__urangezero([21 x i32]* nocapture %a) nounwind {
  65. bb.thread:
  66. br label %bb
  67. bb: ; preds = %bb, %bb.thread
  68. %i.0.reg2mem.0 = phi i8 [ 10, %bb.thread ], [ %tmp7, %bb ] ; <i8> [#uses=2]
  69. %tmp12 = sext i8 %i.0.reg2mem.0 to i32 ; <i32> [#uses=1]
  70. %tmp4 = add i32 %tmp12, -10 ; <i32> [#uses=1]
  71. %tmp5 = getelementptr [21 x i32], [21 x i32]* %a, i32 0, i32 %tmp4 ; <i32*> [#uses=1]
  72. store i32 0, i32* %tmp5
  73. %tmp7 = add i8 %i.0.reg2mem.0, 1 ; <i8> [#uses=2]
  74. %0 = icmp sgt i8 %tmp7, 30 ; <i1> [#uses=1]
  75. br i1 %0, label %return, label %bb
  76. return: ; preds = %bb
  77. ret void
  78. }