Hi Robin,
>> +TargetVariable
>> +int riscv_zvabd_subext
>> +
>> TargetVariable
>> int riscv_zvb_subext
>>
>> @@ -103,9 +109,6 @@ int riscv_zvk_subext
>> TargetVariable
>> int riscv_zvl_subext
>>
>> -TargetVariable
>> -int riscv_zvabd_subext
>> -
>
> Why is this moving? :)
>
The file was regenerated, and the generator automatically sorted them. Perhaps
the file hadn't been regenerated using the generator in the original Zvabd
patch.
> I just realized that this already exists for aarch64 as well as x86.
> Long term surely something common code should do but for now we need to
> handle it ourselves. The function itself seems ok to me but its usage
> seems a bit peculiar :)
>
> IMHO the order should be roughly:
> (1) Coalesce/reencode the perm
> (2) Try patterns with the reencoded perm (except the generic fallback)
> (3) Try wit the original perm (except fallback)
> (4) Try reencoded fallback
> (5) Try fallback.
>
> But I suppose that would create a bit of churn and might change a few
> test expectations. Thus, how about we leave the coalescing out of this
> patch, also out of the new even/odd patterns and do it as a follow up?
This looks like the ordering of the AArch64 counterpart. I adopted the
current order on purpose because we prefer reencoded xt.vil[eo] to some
other regular perm patterns based on performance considerations (so that
it's xt.vil > reencoded xt.vil > other possible instructions). Not
universal though, and I'll the adopt your ordering in the follow-up, along
with the changes suggested by Sashiko. Hopefully we'll finally be able to
take the costs into account in perm generation, but that will be yet another
topic.
>
>> +(define_insn "@xt_pred_<xxtvarith_ins_name><mode>"
>> + [(set (match_operand:V_VLS 0 "register_operand" "=vr, vr")
>> + (if_then_else:V_VLS
>> + (unspec:<VM>
>> + [(match_operand 4 "vector_length_operand" " rK, rK")
>> + (match_operand 5 "const_int_operand" " i, i")
>> + (match_operand 6 "const_int_operand" " i, i")
>> + (reg:SI VL_REGNUM)
>> + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
>> + (unspec:V_VLS
>> + [(match_operand:V_VLS 2 "register_operand" "vr,vr")
>> + (match_operand:V_VLS 3 "register_operand" "vr,vr")] UNSPEC_XT_VIL_IT)
>> + (match_operand:V_VLS 1 "vector_merge_operand" "vu,0")))]
>> + "TARGET_VECTOR && TARGET_XXTVARITH"
>> + "xt.<xxtvarith_ins_name>.vv\t%0,%2,%3"
>> + [(set_attr "type" "xt_<xxtvarith_ins_name>")
>> + (set_attr "mode" "<MODE>")
>> + (set_attr "merge_op_idx" "1")
>> + (set_attr "vl_op_idx" "4")
>> + (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
>> + (set (attr "avl_type_idx") (const_int 6))])
>
> Are all these attributes necessary? Didn't you already add them to the
> attribute list?
>
Oops, leftover. I'll clean them up in v3.
>> diff --git a/gcc/testsuite/lib/target-supports.exp
>> b/gcc/testsuite/lib/target-supports.exp
>> index 3c5dfd59f6f..6c93c7375b6 100644
>> --- a/gcc/testsuite/lib/target-supports.exp
>> +++ b/gcc/testsuite/lib/target-supports.exp
>> @@ -2349,6 +2349,17 @@ proc check_effective_target_riscv_zbkc { } {
>> }]
>> }
>>
>> +# Return 1 if the target arch supports the XXTVarith extension, 0 otherwise.
>> +# Cache the result.
>> +
>> +proc check_effective_target_riscv_xxtvarith { } {
>> + return [check_no_compiler_messages riscv_ext_xxtvarith assembly {
>> + #ifndef __riscv_xxtvarith
>> + #error "Not __riscv_xxtvarith"
>> + #endif
>> + }]
>> +}
>
> Wouldn't you rather want a runtime check here? In the end I don't mind
> too much as I trust you have done the testing but from a consistency
> perspective I'd prefer a real check. Not a blocker, your call.
>
I'll add the "ok" checks in v3.
V3 is going to be sent soon, without the coalescing part.
Thanks,
Bohan