On 04/29/2016 07:54 AM, Liu Woon Yung wrote:
I've done something like that, but GCC still doesn't select the pattern to use:
(define_insn "vec_cmp<MMI_VCMP_OP:code><MMI_VWHB:mode>"
Because you've used the wrong name. The patterns are:
OPTAB_CD(vec_cmp_optab, "vec_cmp$a$b")
OPTAB_CD(vec_cmpu_optab, "vec_cmpu$a$b")
I see where the confusion is though. These:
i386/sse.md:(define_expand "vec_cmp<mode><avx512fmaskmodelower>"
i386/sse.md:(define_expand "vec_cmp<mode><avx512fmaskmodelower>"
i386/sse.md:(define_expand "vec_cmp<mode><sseintvecmodelower>"
i386/sse.md:(define_expand "vec_cmp<mode><sseintvecmodelower>"
i386/sse.md:(define_expand "vec_cmpv2div2di"
i386/sse.md:(define_expand "vec_cmp<mode><sseintvecmodelower>"
i386/sse.md:(define_expand "vec_cmp<mode><sseintvecmodelower>"
i386/sse.md:(define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
i386/sse.md:(define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
i386/sse.md:(define_expand "vec_cmpu<mode><sseintvecmodelower>"
i386/sse.md:(define_expand "vec_cmpu<mode><sseintvecmodelower>"
i386/sse.md:(define_expand "vec_cmpuv2div2di"
are the only usage examples within the gcc tree.
All of the other "vec_cmp<code>" stuff that you're seeing are internal to the
rs6000 and s390 ports, for implementing builtins and/or vcond.
rs6000 doesn't implement bare comparisons, but only implements the "vcond"
conditional move upon which uses the comparison. Many of the other targets
do the same thing.
Is there a reason why implementing only vcond is preferred?
I believe that's just history. IIRC, only vcond was present originally.
Amusingly, I believe that was because vcond was designed to handle one of the
other MIPS vector extensions (MDMX?) wherein the comparison results are placed
in (a set of) condition code registers, and thus producing a per-element {0,-1}
vector result requires extra instructions.
r~