|
1 | 1 | // |
2 | | -// Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | // Copyright (c) 2020, 2023, Arm Limited. All rights reserved. |
4 | 4 | // Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. |
5 | 5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
@@ -109,6 +109,13 @@ source %{ |
109 | 109 | if (!UseRVV) { |
110 | 110 | return false; |
111 | 111 | } |
| 112 | + switch (opcode) { |
| 113 | + case Op_SelectFromTwoVector: |
| 114 | + // There is no masked version of selectFrom two vector, i.e. selectFrom(av, bv, mask) in vector API. |
| 115 | + return false; |
| 116 | + default: |
| 117 | + break; |
| 118 | + } |
112 | 119 | return match_rule_supported_vector(opcode, vlen, bt); |
113 | 120 | } |
114 | 121 |
|
@@ -4425,6 +4432,34 @@ instruct vmask_reinterpret_diff_esize(vRegMask dst, vRegMask_V0 src, vReg tmp) % |
4425 | 4432 | ins_pipe(pipe_slow); |
4426 | 4433 | %} |
4427 | 4434 |
|
| 4435 | +// ------------------------------ Vector selectFrom ----------------------------- |
| 4436 | + |
| 4437 | +instruct select_from_two_vectors(vReg dst, vReg src1, vReg src2, vReg index, vRegMask_V0 v0, vReg tmp) %{ |
| 4438 | + match(Set dst (SelectFromTwoVector (Binary index src1) src2)); |
| 4439 | + effect(TEMP_DEF dst, TEMP v0, TEMP tmp); |
| 4440 | + format %{ "select_from_two_vectors $dst, $src1, $src2, $index" %} |
| 4441 | + ins_encode %{ |
| 4442 | + BasicType bt = Matcher::vector_element_basic_type(this); |
| 4443 | + __ vsetvli_helper(bt, Matcher::vector_length(this)); |
| 4444 | + __ vrgather_vv(as_VectorRegister($dst$$reg), as_VectorRegister($src1$$reg), |
| 4445 | + as_VectorRegister($index$$reg)); |
| 4446 | + bool use_imm = __ is_simm5(Matcher::vector_length(this) - 1); |
| 4447 | + if (use_imm) { |
| 4448 | + __ vmsgtu_vi(v0, as_VectorRegister($index$$reg), Matcher::vector_length(this) - 1); |
| 4449 | + __ vadd_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($index$$reg), |
| 4450 | + -Matcher::vector_length(this), Assembler::v0_t); |
| 4451 | + } else { |
| 4452 | + __ mv(t0, Matcher::vector_length(this) - 1); |
| 4453 | + __ vmsgtu_vx(v0, as_VectorRegister($index$$reg), t0); |
| 4454 | + __ mv(t0, -Matcher::vector_length(this)); |
| 4455 | + __ vadd_vx(as_VectorRegister($tmp$$reg), as_VectorRegister($index$$reg), t0, Assembler::v0_t); |
| 4456 | + } |
| 4457 | + __ vrgather_vv(as_VectorRegister($dst$$reg), as_VectorRegister($src2$$reg), |
| 4458 | + as_VectorRegister($tmp$$reg), Assembler::v0_t); |
| 4459 | + %} |
| 4460 | + ins_pipe(pipe_slow); |
| 4461 | +%} |
| 4462 | + |
4428 | 4463 | // ------------------------------ Vector rearrange ----------------------------- |
4429 | 4464 |
|
4430 | 4465 | instruct rearrange(vReg dst, vReg src, vReg shuffle) %{ |
|
0 commit comments