File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -1759,7 +1759,7 @@ struct OptimizeInstructions
1759
1759
}
1760
1760
}
1761
1761
if (canOptimize) {
1762
- cast->type = Type ( cast->type .getHeapType (), NonNullable);
1762
+ cast->type = cast->type .with ( NonNullable);
1763
1763
}
1764
1764
}
1765
1765
}
@@ -2583,7 +2583,7 @@ struct OptimizeInstructions
2583
2583
// The cast cannot be non-nullable, or we would have handled this right
2584
2584
// above by just removing the ref.as, since it would not be needed.
2585
2585
assert (!cast->type .isNonNullable ());
2586
- cast->type = Type ( cast->type .getHeapType (), NonNullable);
2586
+ cast->type = cast->type .with ( NonNullable);
2587
2587
replaceCurrent (cast);
2588
2588
}
2589
2589
}
Original file line number Diff line number Diff line change 6
6
;; CHECK: (type $foo (sub (struct)))
7
7
(type $foo (sub (struct )))
8
8
9
- ;; CHECK: (func $ref-cast-exact-fallthrough (type $1 ) (param $exact (ref (exact $foo))) (result (ref $foo))
9
+ ;; CHECK: (func $ref-cast-exact-fallthrough (type $2 ) (param $exact (ref (exact $foo))) (result (ref $foo))
10
10
;; CHECK-NEXT: (local $inexact (ref $foo))
11
11
;; CHECK-NEXT: (local $2 (ref (exact $foo)))
12
12
;; CHECK-NEXT: (drop
29
29
)
30
30
)
31
31
32
- ;; CHECK: (func $prefer-exactness (type $2 ) (param $exact-null (ref null (exact $foo))) (result (ref $foo))
32
+ ;; CHECK: (func $prefer-exactness (type $3 ) (param $exact-null (ref null (exact $foo))) (result (ref $foo))
33
33
;; CHECK-NEXT: (local $inexact-nn (ref $foo))
34
34
;; CHECK-NEXT: (local $inexact-null (ref null $foo))
35
35
;; CHECK-NEXT: (local $3 (ref null (exact $foo)))
64
64
)
65
65
)
66
66
67
- ;; CHECK: (func $combine-non-null (type $3 ) (param $foo (ref null $foo)) (result (ref (exact $foo)))
67
+ ;; CHECK: (func $combine-non-null (type $1 ) (param $foo (ref null $foo)) (result (ref (exact $foo)))
68
68
;; CHECK-NEXT: (ref.cast (ref (exact $foo))
69
69
;; CHECK-NEXT: (local.get $foo)
70
70
;; CHECK-NEXT: )
78
78
)
79
79
)
80
80
)
81
+
82
+ ;; CHECK: (func $combine-non-null-reverse (type $1) (param $foo (ref null $foo)) (result (ref (exact $foo)))
83
+ ;; CHECK-NEXT: (ref.cast (ref (exact $foo))
84
+ ;; CHECK-NEXT: (local.get $foo)
85
+ ;; CHECK-NEXT: )
86
+ ;; CHECK-NEXT: )
87
+ (func $combine-non-null-reverse (param $foo (ref null $foo )) (result (ref (exact $foo )))
88
+ ;; As above, but flipped.
89
+ (ref.as_non_null
90
+ (ref.cast (ref null (exact $foo ))
91
+ (local.get $foo )
92
+ )
93
+ )
94
+ )
81
95
)
You can’t perform that action at this time.
0 commit comments