or_empty_block.carbon 977 B

1234567891011121314151617181920212223242526
  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 Or(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 or c;
  10. }
  11. // CHECK:STDOUT: ; ModuleID = 'or_empty_block.carbon'
  12. // CHECK:STDOUT: source_filename = "or_empty_block.carbon"
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: define i1 @Or(i1 %b, i1 %c) {
  15. // CHECK:STDOUT: %1 = xor i1 %b, true
  16. // CHECK:STDOUT: br i1 %1, label %2, label %3
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: 2: ; preds = %0
  19. // CHECK:STDOUT: br label %3
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: 3: ; preds = %2, %0
  22. // CHECK:STDOUT: %4 = phi i1 [ true, %0 ], [ %c, %2 ]
  23. // CHECK:STDOUT: ret i1 %4
  24. // CHECK:STDOUT: }