[compiler] Fix a bug in MachineOperatorReducer's BitfieldCheck
Bug: chromium:1234770 Change-Id: I7368c4bcebc9b4ae78291e9e7bfc860328a742ae Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3068941 Reviewed-by: Seth Brenith <seth.brenith@microsoft.com> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#76062}
This commit is contained in:
parent
27a517b892
commit
574ca6b71c
@ -1718,11 +1718,21 @@ Reduction MachineOperatorReducer::ReduceWordNAnd(Node* node) {
|
||||
namespace {
|
||||
|
||||
// Represents an operation of the form `(source & mask) == masked_value`.
|
||||
// where each bit set in masked_value also has to be set in mask.
|
||||
struct BitfieldCheck {
|
||||
Node* source;
|
||||
uint32_t mask;
|
||||
uint32_t masked_value;
|
||||
bool truncate_from_64_bit;
|
||||
Node* const source;
|
||||
uint32_t const mask;
|
||||
uint32_t const masked_value;
|
||||
bool const truncate_from_64_bit;
|
||||
|
||||
BitfieldCheck(Node* source, uint32_t mask, uint32_t masked_value,
|
||||
bool truncate_from_64_bit)
|
||||
: source(source),
|
||||
mask(mask),
|
||||
masked_value(masked_value),
|
||||
truncate_from_64_bit(truncate_from_64_bit) {
|
||||
CHECK_EQ(masked_value & ~mask, 0);
|
||||
}
|
||||
|
||||
static base::Optional<BitfieldCheck> Detect(Node* node) {
|
||||
// There are two patterns to check for here:
|
||||
@ -1737,14 +1747,16 @@ struct BitfieldCheck {
|
||||
if (eq.left().IsWord32And()) {
|
||||
Uint32BinopMatcher mand(eq.left().node());
|
||||
if (mand.right().HasResolvedValue() && eq.right().HasResolvedValue()) {
|
||||
BitfieldCheck result{mand.left().node(), mand.right().ResolvedValue(),
|
||||
eq.right().ResolvedValue(), false};
|
||||
uint32_t mask = mand.right().ResolvedValue();
|
||||
uint32_t masked_value = eq.right().ResolvedValue();
|
||||
if ((masked_value & ~mask) != 0) return {};
|
||||
if (mand.left().IsTruncateInt64ToInt32()) {
|
||||
result.truncate_from_64_bit = true;
|
||||
result.source =
|
||||
NodeProperties::GetValueInput(mand.left().node(), 0);
|
||||
return BitfieldCheck(
|
||||
NodeProperties::GetValueInput(mand.left().node(), 0), mask,
|
||||
masked_value, true);
|
||||
} else {
|
||||
return BitfieldCheck(mand.left().node(), mask, masked_value, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user