switch-to-select-multiple-edge-per-block-phi.ll 907 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ; RUN: opt < %s -simplifycfg -S | FileCheck %s
  2. ; a, b;
  3. ; fn1() {
  4. ; if (b)
  5. ; if (a == 0 || a == 5)
  6. ; return a;
  7. ; return 0;
  8. ; }
  9. ; Checking that we handle correctly the case when we have a switch
  10. ; branching multiple times to the same block
  11. @b = common global i32 0, align 4
  12. @a = common global i32 0, align 4
  13. ; Function Attrs: nounwind
  14. define i32 @fn1() {
  15. ; CHECK-LABEL: @fn1
  16. ; CHECK: %switch.selectcmp1 = icmp eq i32 %1, 5
  17. ; CHECK: %switch.select2 = select i1 %switch.selectcmp1, i32 5, i32 %switch.select
  18. entry:
  19. %0 = load i32, i32* @b, align 4
  20. %tobool = icmp eq i32 %0, 0
  21. br i1 %tobool, label %if.end3, label %if.then
  22. if.then:
  23. %1 = load i32, i32* @a, align 4
  24. switch i32 %1, label %if.end3 [
  25. i32 5, label %return
  26. i32 0, label %return
  27. ]
  28. if.end3:
  29. br label %return
  30. return:
  31. %retval.0 = phi i32 [ 0, %if.end3 ], [ %1, %if.then ], [ %1, %if.then ]
  32. ret i32 %retval.0
  33. }