cf.do.continue.hlsl 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Run: %dxc -T ps_6_0 -E main
  2. int foo() { return true; }
  3. void main() {
  4. int val = 0;
  5. int i = 0;
  6. // CHECK: OpBranch %do_while_header
  7. // CHECK-NEXT: %do_while_header = OpLabel
  8. // CHECK-NEXT: OpLoopMerge %do_while_merge %do_while_continue None
  9. // CHECK-NEXT: OpBranch %do_while_body
  10. do {
  11. // CHECK-NEXT: %do_while_body = OpLabel
  12. ++i;
  13. // CHECK: OpSelectionMerge %if_merge None
  14. // CHECK-NEXT: OpBranchConditional {{%\d+}} %if_true %if_merge
  15. if (i > 5) {
  16. // CHECK-NEXT: %if_true = OpLabel
  17. // CHECK-NEXT: OpBranch %do_while_continue
  18. {{continue;}}
  19. val = i; // No SPIR-V should be emitted for this statement.
  20. while(true); // No SPIR-V should be emitted for this statement.
  21. }
  22. // CHECK-NEXT: %if_merge = OpLabel
  23. val = i;
  24. // CHECK: OpBranch %do_while_continue
  25. continue;
  26. val = val * 2; // No SPIR-V should be emitted for this statement.
  27. continue; // No SPIR-V should be emitted for this statement.
  28. // CHECK-NEXT: %do_while_continue = OpLabel
  29. // CHECK: OpBranchConditional {{%\d+}} %do_while_header %do_while_merge
  30. } while (i < 10);
  31. // CHECK-NEXT: %do_while_merge = OpLabel
  32. //////////////////////////////////////////////////////////////////////////////////////
  33. // Nested do-while loops with continue statements //
  34. // Each continue statement should branch to the corresponding loop's continue block //
  35. //////////////////////////////////////////////////////////////////////////////////////
  36. // CHECK-NEXT: OpBranch %do_while_header_0
  37. // CHECK-NEXT: %do_while_header_0 = OpLabel
  38. // CHECK-NEXT: OpLoopMerge %do_while_merge_1 %do_while_continue_1 None
  39. // CHECK-NEXT: OpBranch %do_while_body_0
  40. do {
  41. // CHECK-NEXT: %do_while_body_0 = OpLabel
  42. ++i;
  43. // CHECK: OpBranch %do_while_header_1
  44. // CHECK-NEXT: %do_while_header_1 = OpLabel
  45. // CHECK-NEXT: OpLoopMerge %do_while_merge_0 %do_while_continue_0 None
  46. // CHECK-NEXT: OpBranch %do_while_body_1
  47. do {
  48. // CHECK-NEXT: %do_while_body_1 = OpLabel
  49. ++val;
  50. // CHECK: OpBranch %do_while_continue_0
  51. continue;
  52. // CHECK-NEXT: %do_while_continue_0 = OpLabel
  53. // CHECK: OpBranchConditional {{%\d+}} %do_while_header_1 %do_while_merge_0
  54. } while (i < 10);
  55. // CHECK-NEXT: %do_while_merge_0 = OpLabel
  56. --i;
  57. // CHECK: OpBranch %do_while_continue_1
  58. continue;
  59. continue; // No SPIR-V should be emitted for this statement.
  60. // CHECK-NEXT: %do_while_continue_1 = OpLabel
  61. // CHECK: OpBranchConditional {{%\d+}} %do_while_header_0 %do_while_merge_1
  62. } while(val < 10);
  63. // CHECK-NEXT: %do_while_merge_1 = OpLabel
  64. }