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