File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -477,9 +477,10 @@ static SILValue simplifyBuiltin(BuiltinInst *BI) {
477
477
switch (Builtin.ID ) {
478
478
default : break ;
479
479
480
+ case BuiltinValueKind::ZExtOrBitCast:
480
481
case BuiltinValueKind::SExtOrBitCast: {
481
482
const SILValue &Op = Args[0 ];
482
- // extOrBitCast_N_N(x) -> x
483
+ // [s|z] extOrBitCast_N_N(x) -> x
483
484
if (Op->getType () == BI->getType ())
484
485
return Op;
485
486
}
Original file line number Diff line number Diff line change @@ -118,6 +118,17 @@ bb0(%x : $Builtin.Int64):
118
118
// CHECK: return %0 : $Builtin.Int64
119
119
}
120
120
121
+ // Simplify zext((x)) -> x with same type
122
+ sil @fold_zext_n_to_n : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
123
+ bb0(%x : $Builtin.Int64):
124
+ %trunc = builtin "zextOrBitCast_Int64_Int64"(%x : $Builtin.Int64) : $Builtin.Int64
125
+ return %trunc : $Builtin.Int64
126
+
127
+ // CHECK-LABEL: sil @fold_zext_n_to_n
128
+ // CHECK-NOT: builtin
129
+ // CHECK: return %0 : $Builtin.Int64
130
+ }
131
+
121
132
class IntClass {
122
133
@sil_stored var value: Builtin.Int32 { get set }
123
134
init(value: Builtin.Int32)
You can’t perform that action at this time.
0 commit comments