define <4 x i32> @absd_int32_ugt(<4 x i32>, <4 x i32>) { %3 = icmp ugt <4 x i32> %0, %1 %4 = sub <4 x i32> %0, %1 %5 = sub <4 x i32> %1, %0 %6 = select <4 x i1> %3, <4 x i32> %4, <4 x i32> %5 ret <4 x i32> %6 }
For the above vector select case, even on Power9, we generate
vcmpgtuw v4, v2, v3 vsubuwm v5, v2, v3 vsubuwm v2, v3, v2 xxsel v2, v2, v5, v4 blr
Power9 new instructions vabsdu* can be used and got the below optimized code:
vabsduw v2, v2, v3 blr