|
1 | 1 | // RUN: %target-sil-opt -enable-sil-verify-all %s -merge-cond_fails | %FileCheck %s
|
| 2 | +// RUN: %target-sil-opt -enable-sil-verify-all %s -merge-cond_fails -mergeable-traps | %FileCheck %s --check-prefix CHECK-FORCE-MERGE |
2 | 3 |
|
3 | 4 | // REQUIRES: swift_in_compiler
|
4 | 5 |
|
@@ -36,3 +37,46 @@ bb0 (%0 : $Builtin.Int1, %1 : $Builtin.Int1, %2 : $Builtin.Int1, %3: $Builtin.In
|
36 | 37 | cond_fail %10 : $Builtin.Int1
|
37 | 38 | return %9 : $Builtin.Int64
|
38 | 39 | }
|
| 40 | + |
| 41 | +// CHECK-LABEL: sil @nonmergeable_cond_fail |
| 42 | +// CHECK: bb0([[ARG1:%.*]] : $Builtin.Int1, [[ARG2:%.*]] : $Builtin.Int1, [[ARG3:%.*]] : $Builtin.Int1, [[ARG4:%.*]] : $Builtin.Int1, [[ARG5:%.*]] : $*Builtin.Int64): |
| 43 | +// CHECK: {{ cond_fail}} |
| 44 | +// CHECK: {{ cond_fail}} |
| 45 | +// CHECK: [[LD:%.*]] = load [[ARG5]] |
| 46 | +// CHECK: {{ cond_fail}} |
| 47 | +// CHECK: {{ cond_fail}} |
| 48 | +// CHECK: [[TUPLE:%.*]] = builtin "sadd_with_overflow_Int64" |
| 49 | +// CHECK: [[RES:%.*]] = tuple_extract [[TUPLE]]{{.*}}, 0 |
| 50 | +// CHECK: [[OVERFLOW:%.*]] = tuple_extract [[TUPLE]]{{.*}}, 1 |
| 51 | +// CHECK: {{ cond_fail}} |
| 52 | +// CHECK: return [[RES]] |
| 53 | + |
| 54 | +// CHECK-FORCE-MERGE-LABEL: sil @nonmergeable_cond_fail |
| 55 | +// CHECK-FORCE-MERGE: bb0([[ARG1:%.*]] : $Builtin.Int1, [[ARG2:%.*]] : $Builtin.Int1, [[ARG3:%.*]] : $Builtin.Int1, [[ARG4:%.*]] : $Builtin.Int1, [[ARG5:%.*]] : $*Builtin.Int64): |
| 56 | +// CHECK-FORCE-MERGE: [[COND1:%.*]] = builtin "or_Int1"([[ARG1]]{{.*}}, [[ARG2]] |
| 57 | +// CHECK-FORCE-MERGE: {{ cond_fail}} [[COND1]] |
| 58 | +// CHECK-FORCE-MERGE-NOT: {{ cond_fail}} |
| 59 | +// CHECK-FORCE-MERGE: [[LD:%.*]] = load [[ARG5]] |
| 60 | +// CHECK-FORCE-MERGE: [[COND2:%.*]] = builtin "or_Int1"([[ARG3]]{{.*}}, [[ARG4]] |
| 61 | +// CHECK-FORCE-MERGE: {{ cond_fail}} [[COND2]] |
| 62 | +// CHECK-FORCE-MERGE: [[TUPLE:%.*]] = builtin "sadd_with_overflow_Int64" |
| 63 | +// CHECK-FORCE-MERGE: [[RES:%.*]] = tuple_extract [[TUPLE]]{{.*}}, 0 |
| 64 | +// CHECK-FORCE-MERGE: [[OVERFLOW:%.*]] = tuple_extract [[TUPLE]]{{.*}}, 1 |
| 65 | +// CHECK-FORCE-MERGE: {{ cond_fail}} [[OVERFLOW]] |
| 66 | +// CHECK-FORCE-MERGE: return [[RES]] |
| 67 | + |
| 68 | +sil @nonmergeable_cond_fail : $@convention(thin) (Builtin.Int1, Builtin.Int1, Builtin.Int1, Builtin.Int1, @inout Builtin.Int64) -> Builtin.Int64 { |
| 69 | +bb0 (%0 : $Builtin.Int1, %1 : $Builtin.Int1, %2 : $Builtin.Int1, %3: $Builtin.Int1, %4 : $*Builtin.Int64): |
| 70 | + cond_fail %0 : $Builtin.Int1, "message1" |
| 71 | + cond_fail %1 : $Builtin.Int1, "message2" |
| 72 | + %5 = load %4 : $*Builtin.Int64 |
| 73 | + cond_fail %2 : $Builtin.Int1, "message3" |
| 74 | + cond_fail %3 : $Builtin.Int1, "message4" |
| 75 | + %6 = integer_literal $Builtin.Int1, -1 |
| 76 | + %7 = integer_literal $Builtin.Int64, 1 |
| 77 | + %8 = builtin "sadd_with_overflow_Int64"(%5 : $Builtin.Int64, %7 : $Builtin.Int64, %6 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1) |
| 78 | + %9 = tuple_extract %8 : $(Builtin.Int64, Builtin.Int1), 0 |
| 79 | + %10 = tuple_extract %8 : $(Builtin.Int64, Builtin.Int1), 1 |
| 80 | + cond_fail %10 : $Builtin.Int1, "message5" |
| 81 | + return %9 : $Builtin.Int64 |
| 82 | +} |
0 commit comments