File: move_cond_fail_simplify_cfg.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (45 lines) | stat: -rw-r--r-- 1,879 bytes parent folder | download | duplicates (2)
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 : $()
}