return ReplaceBool(m.left().Value() < m.right().Value());
}
if (m.LeftEqualsRight()) return ReplaceBool(false); // x < x => false
+ if (m.left().IsWord32Sar() && m.right().HasValue()) {
+ Int32BinopMatcher mleft(m.left().node());
+ if (mleft.right().HasValue()) {
+ // (x >> K) < C => x < (C << K) | (2^K - 1)
+ // when C < (M >> K)
+ const uint32_t c = m.right().Value();
+ const uint32_t k = mleft.right().Value() & 0x1f;
+ if (c < static_cast<uint32_t>(kMaxInt >> k)) {
+ node->ReplaceInput(0, mleft.left().node());
+ node->ReplaceInput(1, Uint32Constant((c << k) | ((1 << k) - 1)));
+ return Changed(node);
+ }
+ }
+ }
break;
}
case IrOpcode::kUint32LessThanOrEqual: {
IS_BINOP_MATCHER(Word64Equal)
IS_BINOP_MATCHER(Int32AddWithOverflow)
IS_BINOP_MATCHER(Int32Mul)
+IS_BINOP_MATCHER(Uint32LessThan)
IS_BINOP_MATCHER(Uint32LessThanOrEqual)
#undef IS_BINOP_MATCHER
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsUint32LessThan(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
// -----------------------------------------------------------------------------
+// Uint32LessThan
+
+
+TEST_F(MachineOperatorReducerTest, Uint32LessThanWithWord32Sar) {
+ Node* const p0 = Parameter(0);
+ TRACED_FORRANGE(uint32_t, shift, 1, 3) {
+ const uint32_t limit = (kMaxInt >> shift) - 1;
+ Node* const node = graph()->NewNode(
+ machine()->Uint32LessThan(),
+ graph()->NewNode(machine()->Word32Sar(), p0, Uint32Constant(shift)),
+ Uint32Constant(limit));
+
+ Reduction r = Reduce(node);
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(
+ r.replacement(),
+ IsUint32LessThan(p0, IsInt32Constant(bit_cast<int32_t>(
+ (limit << shift) | ((1u << shift) - 1)))));
+ }
+}
+
+
+// -----------------------------------------------------------------------------
// Store