Page MenuHomePhabricator

[X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (LLVM side)
AbandonedPublic

Authored by mike.dvoretsky on Apr 17 2018, 7:23 AM.

Details

Summary

This patch lowers the SAD intrinsics to native LLVM IR. Comes with a clang patch (D45722).

Diff Detail

Event Timeline

mike.dvoretsky created this revision.Apr 17 2018, 7:23 AM
craig.topper added inline comments.Apr 17 2018, 10:15 AM
lib/IR/AutoUpgrade.cpp
2389 ↗(On Diff #142771)

Can't N be calculated from CI.getType()?

Updated per comments.

Don't remove the -fast-isel tests - they should be updated to test the generic codegen instead

How much value are we getting out of this change? Does this expose a lot of optimization potential to the middle end? This is a pretty complex sequence. How easy/likely is for the middle end to mess this up and make it hard for the backend to recognize?

mike.dvoretsky added a subscriber: ashlykov.

Fast-isel tests restored and updated.

Updated per comments in the clang part.

How much value are we getting out of this change? Does this expose a lot of optimization potential to the middle end? This is a pretty complex sequence. How easy/likely is for the middle end to mess this up and make it hard for the backend to recognize?

This will be the 3rd code path we'll have for PSADBW recognition.....

llvm/lib/Target/X86/X86ISelLowering.cpp
38075

Can we reuse/tweak matchBinOpReduction to do this for us?

mike.dvoretsky added inline comments.Apr 25 2018, 7:45 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
38075

This is not a scalar reduction. The patterns calls for a sum of specifically formed vectors (hence all the checks below) to form the PSADBW instruction where it is exactly semantically fitting rather than where it can be used as a reduction tool. This is also why the third path to recognize it is being added - other paths use it for reductions and so don't actually need the input pattern to match it in terms of which qword the specific byte corresponds to.

mike.dvoretsky abandoned this revision.Jun 5 2018, 5:18 AM