Improve optimization of int & 0xFFFFFFFF.
Recognize a second operand if its `ToUint32` is `0xFFFFFFFF`, not just the exact value. This includes fx `& -1`, which is output by `toUnsigned(32)`. Change-Id: Ieccb42591efd72b4aae62a7c6e678f05510abdc6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510960 Reviewed-by: Stephen Adams <sra@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
8e2d140fa5
commit
f1fcecc81d
@@ -2847,7 +2847,8 @@ class SsaInstructionSimplifier extends HBaseVisitor<HInstruction>
|
||||
}
|
||||
|
||||
bool _isFull32BitMask(ConstantValue constant) {
|
||||
return constant is IntConstantValue && constant.intValue == _mask32;
|
||||
return constant is IntConstantValue &&
|
||||
constant.intValue.toUnsigned(32) == _mask32;
|
||||
}
|
||||
|
||||
static final _mask32 = BigInt.parse('FFFFFFFF', radix: 16);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Data for a `../codegen_shard*_test.dart` test.
|
||||
|
||||
/*member: main:ignore*/
|
||||
void main() {
|
||||
for (var a in [0x123456789, 0, -2]) {
|
||||
sink = recognizeMask32(a);
|
||||
sink = recognizeMaskToUint32(a);
|
||||
sink = recognizeNegativeMaskToUint32(a);
|
||||
sink = recognizeAndFromToUnsigned(a);
|
||||
}
|
||||
}
|
||||
|
||||
Object? sink;
|
||||
|
||||
@pragma('dart2js:noInline')
|
||||
/*member: recognizeMask32:function(thing) {
|
||||
return thing >>> 0;
|
||||
}*/
|
||||
int recognizeMask32(int thing) {
|
||||
return thing & 0xFFFF_FFFF;
|
||||
}
|
||||
|
||||
@pragma('dart2js:noInline')
|
||||
/*member: recognizeMaskToUint32:function(thing) {
|
||||
return thing >>> 0;
|
||||
}*/
|
||||
int recognizeMaskToUint32(int thing) {
|
||||
return thing & 0xFFFF_FFFF_FFFF;
|
||||
}
|
||||
|
||||
@pragma('dart2js:noInline')
|
||||
/*member: recognizeNegativeMaskToUint32:function(thing) {
|
||||
return thing >>> 0;
|
||||
}*/
|
||||
int recognizeNegativeMaskToUint32(int thing) {
|
||||
return thing & -1;
|
||||
}
|
||||
|
||||
@pragma('dart2js:noInline')
|
||||
/*member: recognizeAndFromToUnsigned:function(thing) {
|
||||
return thing >>> 0;
|
||||
}*/
|
||||
int recognizeAndFromToUnsigned(int thing) {
|
||||
return thing.toUnsigned(32);
|
||||
}
|
||||
Reference in New Issue
Block a user