Index: src/compiler/arm64/instruction-selector-arm64.cc |
diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc |
index 4d48cb93c5f165f8b4ef4a8f5d2f86fac1de3b34..8af97b598ee4e079a1dfd045000b80379d563e1d 100644 |
--- a/src/compiler/arm64/instruction-selector-arm64.cc |
+++ b/src/compiler/arm64/instruction-selector-arm64.cc |
@@ -2138,8 +2138,11 @@ void VisitWord32Compare(InstructionSelector* selector, Node* node, |
MaybeReplaceCmpZeroWithFlagSettingBinop(selector, &node, binop, &opcode, |
cond, cont, &immediate_mode); |
} |
- } else if (m.right().IsInt32Sub()) { |
+ } else if (m.right().IsInt32Sub() && (cond == kEqual || cond == kNotEqual)) { |
// Select negated compare for comparisons with negated right input. |
+ // Only do this for kEqual and kNotEqual, which do not depend on the |
+ // C and V flags, as those flags will be different with CMN when the |
+ // right-hand side of the original subtraction is INT_MIN. |
Node* sub = m.right().node(); |
Int32BinopMatcher msub(sub); |
if (msub.left().Is(0)) { |