SIL: Update formal source type in SimplifyRefCasts when possible

We use the formal source type do decide whether a checked_cast_br is
known to succeed/fail. If we don't update it we loose that optimization

That is:

```
  checked_cast_br AnyObject in %2 : X to X, bb1, bb2
```

Will not be simplified even though the operand and the destintation type
matches.
This commit is contained in:
Arnold Schwaighofer
2025-01-24 17:06:39 -08:00
parent 8853d39c12
commit 0fe3cf0096
9 changed files with 32 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ class X : B {}
// CHECK-LABEL: sil [ossa] @test_ossa :
// CHECK: %0 = alloc_ref
// CHECK-NEXT: checked_cast_br AnyObject in %0 : $X
// CHECK-NEXT: checked_cast_br X in %0 : $X
// CHECK: bb2([[A:%.*]] : @owned $X):
// CHECK-NEXT: [[U:%.*]] = upcast [[A]] : $X to $B, loc "takethis":1:1
// CHECK-NEXT: [[E:%.*]] = init_existential_ref [[U]] {{.+}}, loc "takethis":1:1