Files
sdk/pkg/compiler/test/codegen/data/bitand.dart
T
Lasse R.H. Nielsen f1fcecc81d 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>
2026-06-11 06:09:58 -07:00

50 lines
1.2 KiB
Dart

// 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);
}