dont_insert_redundant_ops.ll 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ; Check that this test makes INDVAR and related stuff dead.
  2. ; RUN: opt < %s -loop-reduce -S | FileCheck %s
  3. ; CHECK: phi
  4. ; CHECK: phi
  5. ; CHECK-NOT: phi
  6. declare i1 @pred()
  7. define void @test1({ i32, i32 }* %P) {
  8. ; <label>:0
  9. br label %Loop
  10. Loop: ; preds = %Loop, %0
  11. %INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=3]
  12. %gep1 = getelementptr { i32, i32 }, { i32, i32 }* %P, i32 %INDVAR, i32 0 ; <i32*> [#uses=1]
  13. store i32 0, i32* %gep1
  14. %gep2 = getelementptr { i32, i32 }, { i32, i32 }* %P, i32 %INDVAR, i32 1 ; <i32*> [#uses=1]
  15. store i32 0, i32* %gep2
  16. %INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
  17. %cond = call i1 @pred( ) ; <i1> [#uses=1]
  18. br i1 %cond, label %Loop, label %Out
  19. Out: ; preds = %Loop
  20. ret void
  21. }
  22. define void @test2([2 x i32]* %P) {
  23. ; <label>:0
  24. br label %Loop
  25. Loop: ; preds = %Loop, %0
  26. %INDVAR = phi i32 [ 0, %0 ], [ %INDVAR2, %Loop ] ; <i32> [#uses=3]
  27. %gep1 = getelementptr [2 x i32], [2 x i32]* %P, i32 %INDVAR, i64 0 ; <i32*> [#uses=1]
  28. store i32 0, i32* %gep1
  29. %gep2 = getelementptr [2 x i32], [2 x i32]* %P, i32 %INDVAR, i64 1 ; <i32*> [#uses=1]
  30. store i32 0, i32* %gep2
  31. %INDVAR2 = add i32 %INDVAR, 1 ; <i32> [#uses=1]
  32. %cond = call i1 @pred( ) ; <i1> [#uses=1]
  33. br i1 %cond, label %Loop, label %Out
  34. Out: ; preds = %Loop
  35. ret void
  36. }