PhiEliminate3.ll 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. ; Test merging of blocks containing complex expressions,
  2. ; with various folding thresholds
  3. ;
  4. ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=1 | grep N:
  5. ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | not grep N:
  6. ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | grep M:
  7. ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=7 | not grep M:
  8. ;
  9. define i32 @test(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) {
  10. entry:
  11. br i1 %a, label %M, label %O
  12. O:
  13. br i1 %b, label %P, label %Q
  14. P:
  15. %iaj = add i32 %i, %j
  16. %iajak = add i32 %iaj, %k
  17. br label %N
  18. Q:
  19. %ixj = xor i32 %i, %j
  20. %ixjxk = xor i32 %ixj, %k
  21. br label %N
  22. N:
  23. ; This phi should be foldable if threshold >= 2
  24. %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ]
  25. %Wp2 = add i32 %Wp, %Wp
  26. br label %M
  27. M:
  28. ; This phi should be foldable if threshold >= 7
  29. %W = phi i32 [ %Wp2, %N ], [ 2, %entry ]
  30. %R = add i32 %W, 1
  31. ret i32 %R
  32. }