This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC]Exploit P9 vabsdu for some unsigned integer vselect patterns
ClosedPublic

Authored by jedilyn on Dec 18 2018, 12:30 AM.

Details

Summary
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

Diff Detail

Repository
rL LLVM

Event Timeline

jedilyn created this revision.Dec 18 2018, 12:30 AM
jsji accepted this revision.Dec 18 2018, 7:23 AM

LGTM. Thanks for exploiting vabsd!

This revision is now accepted and ready to land.Dec 18 2018, 7:23 AM
This revision was automatically updated to reflect the committed changes.