This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Generate VHADDs/VHSUBs
ClosedPublic

Authored by oliverlars on Aug 5 2019, 7:29 AM.

Details

Summary

This adds support for generating VHADDs (vector half add) and VHSUBs (vector half sub) from a VSHR (vector shift right) and VADD/VSUB (vector add/sub).

This is done from auto vectorising a loop with a pattern like C[i] = (A[i] + B[i])/2.

The instruction supports both signed and unsigned ints.

Diff Detail

Repository
rL LLVM

Event Timeline

oliverlars created this revision.Aug 5 2019, 7:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2019, 7:29 AM

Hello. Remember to upload with full context (-U999999)! It makes reviews easier.

lib/Target/ARM/ARMInstrMVE.td
1567

I don't think you will need the casts, if you just use the instruction names directly.

So why doesn't sdiv get optimised like udiv..?

oliverlars updated this revision to Diff 213602.Aug 6 2019, 7:20 AM

removed instruction casts

oliverlars marked an inline comment as done.Aug 6 2019, 7:20 AM
dmgreen accepted this revision.Aug 6 2019, 10:26 AM

Looks good to me.

Sam: I think the instruction is just defined like that, unfortunately. It does (A+B) >> 1, not (A+B)/2. So if a+b is signed and turns out to be an odd negative number, the instruction rounds towards -inf, not towards 0.

This revision is now accepted and ready to land.Aug 6 2019, 10:26 AM