[PATCH] Vectorizing abs(char/short/int) on x86.

Uros Bizjak ubizjak@gmail.com
Tue Oct 29 09:18:00 GMT 2013


Hello!

> For the define_expand I added as below, the else body is there to
> avoid fall-through transformations to ABS operation in optabs.c.
> Otherwise ABS will be converted to other operations even that we have
> corresponding instructions from SSSE3.

No, it wont be.

Fallthrough will generate the pattern that will be matched by the insn
pattern above, just like you are doing by hand below.

> (define_expand "abs<mode>2"
>   [(set (match_operand:VI124_AVX2_48_AVX512F 0 "register_operand")
> (abs:VI124_AVX2_48_AVX512F
>  (match_operand:VI124_AVX2_48_AVX512F 1 "nonimmediate_operand")))]
>   "TARGET_SSE2"
> {
>   if (!TARGET_SSSE3)
>     ix86_expand_sse2_abs (operands[0], force_reg (<MODE>mode, operands[1]));

Do you really need force_reg here? You are using generic expanders in
ix86_expand_sse2_abs that can handle non-registers operands just as
well.

>   else
>     emit_insn (gen_rtx_SET (VOIDmode, operands[0],
>    gen_rtx_ABS (<MODE>mode, operands[1])));
>   DONE;
> })

Please note that your mailer mangles indents. Please indent your code correctly.

Uros.



More information about the Gcc-patches mailing list