or_empty_block.carbon 976 B

12345678910111213141516171819202122232425
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // CHECK:STDOUT: ; ModuleID = 'or_empty_block.carbon'
  7. // CHECK:STDOUT: source_filename = "or_empty_block.carbon"
  8. // CHECK:STDOUT:
  9. // CHECK:STDOUT: define i1 @Or(i1 %b, i1 %c) {
  10. // CHECK:STDOUT: %1 = xor i1 %b, true
  11. // CHECK:STDOUT: br i1 %1, label %2, label %3
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: 2: ; preds = %0
  14. // CHECK:STDOUT: br label %3
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: 3: ; preds = %2, %0
  17. // CHECK:STDOUT: %4 = phi i1 [ true, %0 ], [ %c, %2 ]
  18. // CHECK:STDOUT: ret i1 %4
  19. // CHECK:STDOUT: }
  20. fn Or(b: bool, c: bool) -> bool {
  21. // Note that in this case, we must generate an empty block so that the `phi`
  22. // has two distinct predecessors.
  23. return b or c;
  24. }