|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Georg Neis < [email protected]> |
| 3 | +Date: Mon, 9 Aug 2021 09:57:12 +0200 |
| 4 | +Subject: Merged: [compiler] Fix a bug in MachineOperatorReducer's |
| 5 | + BitfieldCheck |
| 6 | + |
| 7 | +Revision: 574ca6b71c6160d38b5fcf4b8e133bc7f6ba2387 |
| 8 | + |
| 9 | +BUG=chromium:1234770 |
| 10 | +NOTRY=true |
| 11 | +NOPRESUBMIT=true |
| 12 | +NOTREECHECKS=true |
| 13 | + |
| 14 | + |
| 15 | +Change-Id: I15af5a94e89b54c2a540442c3544ed459b832e0a |
| 16 | +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3080564 |
| 17 | +Reviewed-by: Lutz Vahl < [email protected]> |
| 18 | +Commit-Queue: Georg Neis < [email protected]> |
| 19 | +Cr-Commit-Position: refs/branch-heads/9.3@{#21} |
| 20 | +Cr-Branched-From: 7744dce208a555494e4a33e24fadc71ea20b3895-refs/heads/9.3.345@{#1} |
| 21 | +Cr-Branched-From: 4b6b4cabf3b6a20cdfda72b369df49f3311c4344-refs/heads/master@{#75728} |
| 22 | + |
| 23 | +diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc |
| 24 | +index 918caaf8fd446750d9d4c38350b3af2f25c9a91f..facfadc3ca99f9d2a554f17b577a3833a9974470 100644 |
| 25 | +--- a/src/compiler/machine-operator-reducer.cc |
| 26 | ++++ b/src/compiler/machine-operator-reducer.cc |
| 27 | +@@ -1706,11 +1706,21 @@ Reduction MachineOperatorReducer::ReduceWordNAnd(Node* node) { |
| 28 | + namespace { |
| 29 | + |
| 30 | + // Represents an operation of the form `(source & mask) == masked_value`. |
| 31 | ++// where each bit set in masked_value also has to be set in mask. |
| 32 | + struct BitfieldCheck { |
| 33 | +- Node* source; |
| 34 | +- uint32_t mask; |
| 35 | +- uint32_t masked_value; |
| 36 | +- bool truncate_from_64_bit; |
| 37 | ++ Node* const source; |
| 38 | ++ uint32_t const mask; |
| 39 | ++ uint32_t const masked_value; |
| 40 | ++ bool const truncate_from_64_bit; |
| 41 | ++ |
| 42 | ++ BitfieldCheck(Node* source, uint32_t mask, uint32_t masked_value, |
| 43 | ++ bool truncate_from_64_bit) |
| 44 | ++ : source(source), |
| 45 | ++ mask(mask), |
| 46 | ++ masked_value(masked_value), |
| 47 | ++ truncate_from_64_bit(truncate_from_64_bit) { |
| 48 | ++ CHECK_EQ(masked_value & ~mask, 0); |
| 49 | ++ } |
| 50 | + |
| 51 | + static base::Optional<BitfieldCheck> Detect(Node* node) { |
| 52 | + // There are two patterns to check for here: |
| 53 | +@@ -1725,14 +1735,16 @@ struct BitfieldCheck { |
| 54 | + if (eq.left().IsWord32And()) { |
| 55 | + Uint32BinopMatcher mand(eq.left().node()); |
| 56 | + if (mand.right().HasResolvedValue() && eq.right().HasResolvedValue()) { |
| 57 | +- BitfieldCheck result{mand.left().node(), mand.right().ResolvedValue(), |
| 58 | +- eq.right().ResolvedValue(), false}; |
| 59 | ++ uint32_t mask = mand.right().ResolvedValue(); |
| 60 | ++ uint32_t masked_value = eq.right().ResolvedValue(); |
| 61 | ++ if ((masked_value & ~mask) != 0) return {}; |
| 62 | + if (mand.left().IsTruncateInt64ToInt32()) { |
| 63 | +- result.truncate_from_64_bit = true; |
| 64 | +- result.source = |
| 65 | +- NodeProperties::GetValueInput(mand.left().node(), 0); |
| 66 | ++ return BitfieldCheck( |
| 67 | ++ NodeProperties::GetValueInput(mand.left().node(), 0), mask, |
| 68 | ++ masked_value, true); |
| 69 | ++ } else { |
| 70 | ++ return BitfieldCheck(mand.left().node(), mask, masked_value, false); |
| 71 | + } |
| 72 | +- return result; |
| 73 | + } |
| 74 | + } |
| 75 | + } else { |
0 commit comments