Ensure users of Replicate are clone compatible

When replicate nodes appear in foldable SVE operations, we need to
ensure prior to folding that all other users of the replicate nodes are
also clone compatible, so that the replicate node is not matched two or
more times.  This patch fixes the failing test in
test/hotspot/jtreg/compiler/vectorapi/TestMaskedNotAllOnes.java.
This commit is contained in:
Ashay Rane 2026-07-20 10:41:18 -05:00
parent 9b69184e56
commit 6e6ec30f22
No known key found for this signature in database
GPG Key ID: 52864602A7AB7825

View File

@ -2679,12 +2679,27 @@ static bool is_vector_mask_not_operand_in_andnot_pattern(Node* n, Node* m) {
return false;
}
static bool are_users_clone_compatible(Node* n, Node* m) {
for (DUIterator_Fast imax, i = m->fast_outs(imax); i < imax; i++) {
Node* use = m->fast_out(i);
if (use == n) {
continue;
}
if (!is_vector_bitwise_not_pattern(use, m) &&
!is_valid_sve_arith_imm_pattern(use, m)) {
return false;
}
}
return true;
}
// Should the matcher clone input 'm' of node 'n'?
bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) {
if (is_vshift_con_pattern(n, m) ||
is_vector_bitwise_not_pattern(n, m) ||
((is_vector_bitwise_not_pattern(n, m) ||
is_valid_sve_arith_imm_pattern(n, m)) &&
are_users_clone_compatible(n, m)) ||
is_vector_mask_not_operand_in_andnot_pattern(n, m) ||
is_valid_sve_arith_imm_pattern(n, m) ||
is_encode_and_store_pattern(n, m)) {
mstack.push(m, Visit);
return true;