share_ivs.ll 744 B

123456789101112131415161718192021222324
  1. ; RUN: opt < %s -loop-reduce -S | grep phi | count 1
  2. ; This testcase should have ONE stride 18 indvar, the other use should have a
  3. ; loop invariant value (B) added to it inside of the loop, instead of having
  4. ; a whole indvar based on B for it.
  5. declare i1 @cond(i32)
  6. define void @test(i32 %B) {
  7. ; <label>:0
  8. br label %Loop
  9. Loop: ; preds = %Loop, %0
  10. %IV = phi i32 [ 0, %0 ], [ %IVn, %Loop ] ; <i32> [#uses=3]
  11. %C = mul i32 %IV, 18 ; <i32> [#uses=1]
  12. %D = mul i32 %IV, 18 ; <i32> [#uses=1]
  13. %E = add i32 %D, %B ; <i32> [#uses=1]
  14. %cnd = call i1 @cond( i32 %E ) ; <i1> [#uses=1]
  15. call i1 @cond( i32 %C ) ; <i1>:1 [#uses=0]
  16. %IVn = add i32 %IV, 1 ; <i32> [#uses=1]
  17. br i1 %cnd, label %Loop, label %Out
  18. Out: ; preds = %Loop
  19. ret void
  20. }