and_empty_block.carbon 942 B

123456789101112131415161718192021222324
  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 = 'and_empty_block.carbon'
  7. // CHECK:STDOUT: source_filename = "and_empty_block.carbon"
  8. // CHECK:STDOUT:
  9. // CHECK:STDOUT: define i1 @And(i1 %b, i1 %c) {
  10. // CHECK:STDOUT: br i1 %b, label %1, label %2
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: 1: ; preds = %0
  13. // CHECK:STDOUT: br label %2
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: 2: ; preds = %1, %0
  16. // CHECK:STDOUT: %3 = phi i1 [ false, %0 ], [ %c, %1 ]
  17. // CHECK:STDOUT: ret i1 %3
  18. // CHECK:STDOUT: }
  19. fn And(b: bool, c: bool) -> bool {
  20. // Note that in this case, we must generate an empty block so that the `phi`
  21. // has two distinct predecessors.
  22. return b and c;
  23. }