2014-06-11-SwitchDefaultUnreachableOpt.ll 670 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ; RUN: opt < %s -lowerswitch -S | FileCheck %s
  2. ;
  3. ; The switch is lowered with a single icmp.
  4. ; CHECK: icmp
  5. ; CHECK-NOT: icmp
  6. ;
  7. ;int foo(int a) {
  8. ;
  9. ; switch (a) {
  10. ; case 0:
  11. ; return 10;
  12. ; case 1:
  13. ; return 3;
  14. ; default:
  15. ; __builtin_unreachable();
  16. ; }
  17. ;
  18. ;}
  19. define i32 @foo(i32 %a) {
  20. %1 = alloca i32, align 4
  21. %2 = alloca i32, align 4
  22. store i32 %a, i32* %2, align 4
  23. %3 = load i32, i32* %2, align 4
  24. switch i32 %3, label %6 [
  25. i32 0, label %4
  26. i32 1, label %5
  27. ]
  28. ; <label>:4
  29. store i32 10, i32* %1
  30. br label %7
  31. ; <label>:5
  32. store i32 3, i32* %1
  33. br label %7
  34. ; <label>:6
  35. unreachable
  36. ; <label>:7
  37. %8 = load i32, i32* %1
  38. ret i32 %8
  39. }