The current code sequence & its cycles for vec_abs look like:
signed char: tot cycs: 3+2+3 = 8 xxspltib 35, 128 vaddubm 2, 2, 3 vabsdub 2, 2, 3 signed short: tot cycs: 2+2+3+2+3 = 12 lis 3, -32768 ori 3, 3, 32768 mtvsrws 35, 3 vadduhm 2, 2, 3 vabsduh 2, 2, 3 signed word: tot cycs: 2 (parallel 2) + 2 + 3 = 7 vxor 3, 3, 3 xvnegsp 34, 34 xvnegsp 35, 35 vabsduw 2, 2, 3
It can be better like:
signed char: tot cycs: 2 + 2 + 3 = 7 xxlxor 35, 35, 35 vsububm 3, 3, 2 vmaxsb 2, 2, 3 signed short: tot cycs: 2 + 2 + 3 = 7 xxlxor 35, 35, 35 vsubuhm 3, 3, 2 vmaxsh 2, 2, 3 signed word: tot cycs: 2 + 3 = 5 vnegw 0,2 vmaxsw 2,0,2
The current implementation is intended to use absolute different instructions introduced in Power9, but it's for unsigned integers and we won't see any benefits with more efforts to support it for signed.
In this past, we always expand abs for vector type excepting for power9, this patch is to recognize vector abs as custom, then even if the code doesn't call vec_abs built-in function but the same semantic code sequence, the general combine pass can check and create abs node for vector type. Later if there is any opportunity we can further combine it to others like vabsdu and the abs node can be removed, otherwise it's lowed to vsub + vmax as before.