Hi Segher,

on 2019/11/9 上午1:36, Segher Boessenkool wrote:
> Hi!
> On Fri, Nov 08, 2019 at 10:38:13AM +0800, Kewen.Lin wrote:
>>>> +  [(set (match_operand:<VEC_INT> 0 "vint_operand")
>>>> +   (match_operator 1 "comparison_operator"
>>> If you make an iterator for this instead, it is simpler code (you can then
>>> use <code> to do all these cases in one statement).
>> If my understanding is correct and based on some tries before, I think we
>> have to leave these **CASEs** there (at least at the 1st level define_expand
>> for vec_cmp*), since vec_cmp* doesn't have <code> field in the pattern name.
>> The code can be only extracted from operator 1.  I tried to add one dummy
>> operand to hold <code> but it's impractical.
>> Sorry, I may miss something here, I'm happy to make a subsequent patch to
>> uniform these cases if there is a good way to run a code iterator on them.
> Instead of
>   [(set (match_operand:VEC_I 0 "vint_operand")
>       (match_operator 1 "signed_or_equality_comparison_operator"
>         [(match_operand:VEC_I 2 "vint_operand")
>          (match_operand:VEC_I 3 "vint_operand")]))]
> you can do
>   [(set (match_operand:VEC_I 0 "vint_operand")
>       (some_iter:VEC_I (match_operand:VEC_I 1 "vint_operand")
>                        (match_operand:VEC_I 2 "vint_operand")))]

Thanks for your example.  But I'm afraid that it doesn't work for these 

I tried it with simple code below:

; For testing
(define_code_iterator some_iter [eq gt])

(define_expand "vec_cmp<mode><mode>"
  [(set (match_operand:VEC_I 0 "vint_operand")
      (match_operand:VEC_I 2 "vint_operand")
      (match_operand:VEC_I 3 "vint_operand")))]
  emit_insn (gen_vector_<code><mode> (operands[0], operands[2], operands[3]));

Error messages were emitted:

/home/linkw/gcc/gcc-git-fix/gcc/config/rs6000/vector.md:531:1: duplicate 
definition of 'vec_cmpv16qiv16qi'
/home/linkw/gcc/gcc-git-fix/gcc/config/rs6000/vector.md:531:1: duplicate 
definition of 'vec_cmpv8hiv8hi'
/home/linkw/gcc/gcc-git-fix/gcc/config/rs6000/vector.md:531:1: duplicate 
definition of 'vec_cmpv4siv4si'
/home/linkw/gcc/gcc-git-fix/gcc/config/rs6000/vector.md:531:1: duplicate 
definition of 'vec_cmpv2div2di'

It's expected, since the pattern here is vec_cmp<mode><mode> rather than
vec_cmp<mode><mode><code>, your example would work perfectly for the later.
Btw, in that pattern, the comparison operator is passed in operand 1.


> with some_iter some code_iterator, (note you need to renumber), and in the
> body you can then just use <code> (or <CODE>, or some other code_attribute).
> code_iterator is more flexible than match_operator, in most ways.
> Segher

Reply via email to