File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ struct LocalScanner : PostWalker<LocalScanner> {
129
129
Properties::getFallthrough (curr->value , passOptions, *getModule ());
130
130
auto & info = localInfo[curr->index ];
131
131
info.maxBits = std::max (info.maxBits , Bits::getMaxBits (value, this ));
132
+ info.maxBits = std::min (info.maxBits , getBitsForType (type));
132
133
auto signExtBits = LocalInfo::kUnknown ;
133
134
if (Properties::getSignExtValue (value)) {
134
135
signExtBits = Properties::getSignExtBits (value);
Original file line number Diff line number Diff line change 18410
18410
)
18411
18411
)
18412
18412
)
18413
+
18414
+ ;; CHECK: (func $local-unreachable-size-matters
18415
+ ;; CHECK-NEXT: (local $temp i32)
18416
+ ;; CHECK-NEXT: (local.set $temp
18417
+ ;; CHECK-NEXT: (i32.const 1)
18418
+ ;; CHECK-NEXT: )
18419
+ ;; CHECK-NEXT: (drop
18420
+ ;; CHECK-NEXT: (i32.and
18421
+ ;; CHECK-NEXT: (local.get $temp)
18422
+ ;; CHECK-NEXT: (i32.const 1)
18423
+ ;; CHECK-NEXT: )
18424
+ ;; CHECK-NEXT: )
18425
+ ;; CHECK-NEXT: (local.tee $temp
18426
+ ;; CHECK-NEXT: (unreachable)
18427
+ ;; CHECK-NEXT: )
18428
+ ;; CHECK-NEXT: )
18429
+ (func $local-unreachable-size-matters
18430
+ ;; The local is written 1, then later down we have an unreachable. That
18431
+ ;; should not confuse us as to the max bits in the local. This is a test for
18432
+ ;; a bug where any local with an unreachable set got assigned 64 bits, which
18433
+ ;; is wrong in this case and led to a misoptimization of the |and|. We
18434
+ ;; should not optimize it away to a 0 (we could in theory optimize it to a
18435
+ ;; 1, but this pass does not infer locals that precisely).
18436
+ (local $temp i32 )
18437
+ (local.set $temp
18438
+ (i32.const 1 )
18439
+ )
18440
+ (drop
18441
+ (i32.and
18442
+ (local.get $temp )
18443
+ (i32.const 1 )
18444
+ )
18445
+ )
18446
+ (local.tee $temp
18447
+ (unreachable )
18448
+ )
18449
+ )
18413
18450
)
You can’t perform that action at this time.
0 commit comments