File: move_cond_fail_simplify_cfg.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (45 lines) | stat: -rw-r--r-- 1,879 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// RUN: %target-sil-opt -enable-sil-verify-all %s -move-cond-fail-to-preds | %FileCheck %s

import Builtin
import Swift

sil_stage canonical

// Make sure that we actually check all predecessors when we try to hoist
// cond_fails.
//
// CHECK-LABEL: sil @check_all_preds_when_hoisting_cond_fails : $@convention(thin) (Builtin.Int1) -> () {
sil @check_all_preds_when_hoisting_cond_fails : $@convention(thin) (Builtin.Int1) -> () {
bb0(%0 : $Builtin.Int1):
  %1 = integer_literal $Builtin.Int1, 0
  %2 = integer_literal $Builtin.Int64, 1
  %3 = integer_literal $Builtin.Int64, 3
  cond_br %0, bb3, bb2

// Make sure that the predecessor order here is not changed. This is necessary
// for the test to actually test that we are checking /all/ predecessors.
//
// CHECK: bb1({{.*}}): // Preds: bb2 bb1
bb1(%7 : $Builtin.Int64, %8 : $Builtin.Int64, %9 : $Builtin.Int1):
  %10 = builtin "sadd_with_overflow_Int64"(%8 : $Builtin.Int64, %2 : $Builtin.Int64, %1 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
  %11 = tuple_extract %10 : $(Builtin.Int64, Builtin.Int1), 0
  cond_fail %9 : $Builtin.Int1
  %13 = builtin "sadd_with_overflow_Int64"(%7 : $Builtin.Int64, %2 : $Builtin.Int64, %1 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
  %14 = tuple_extract %13 : $(Builtin.Int64, Builtin.Int1), 0
  %15 = tuple_extract %13 : $(Builtin.Int64, Builtin.Int1), 1
  cond_fail %15 : $Builtin.Int1
  %17 = builtin "cmp_eq_Int64"(%14 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int1
  %18 = builtin "cmp_eq_Int64"(%11 : $Builtin.Int64, %3 : $Builtin.Int64) : $Builtin.Int1
  cond_br %18, bb3, bb1(%14 : $Builtin.Int64, %11 : $Builtin.Int64, %17 : $Builtin.Int1)

// Make sure there can not be any cond_fail here.
// CHECK: bb2:
// CHECK-NEXT: br bb1
bb2:
  br bb1(%2 : $Builtin.Int64, %2 : $Builtin.Int64, %1 : $Builtin.Int1)

// CHECK: bb3:
bb3:
  %5 = tuple()
  return %5 : $()
}