This is an archive of the discontinued LLVM Phabricator instance.

[ARM,AArch64] Fix __rev16l and __rev16ll intrinsics
ClosedPublic

Authored by olista01 on Nov 12 2015, 4:31 AM.

Details

Summary

These two intrinsics are defined in arm_acle.h.

__rev16l needs to rotate by 16 bits, bit it was actually rotating by 2 bits. For AArch64, where long is 64 bits, this would still be wrong.

rev16ll was incorrect, it reversed the bytes in each 32-bit word, rather than each 16-bit halfword. The correct implementation is to apply rev16 to the top and bottom words of the 64-bit value.

For AArch32 targets, these get compiled down to the hardware rev16 instruction at -O1 and above. For AArch64 targets, the 64-bit ones get compiled to two 32-bit rev16 instructions, because there is not currently a pattern for the 64-bit rev16 instruction.

Diff Detail

Repository
rL LLVM

Event Timeline

olista01 updated this revision to Diff 40029.Nov 12 2015, 4:31 AM
olista01 retitled this revision from to [ARM,AArch64] Fix __rev16l and __rev16ll intrinsics.
olista01 updated this object.
olista01 set the repository for this revision to rL LLVM.
olista01 added a subscriber: cfe-commits.
rengolin accepted this revision.Nov 16 2015, 6:56 AM
rengolin added a reviewer: rengolin.

LGTM. The 64-bit rev pattern can be added later. Thanks!

This revision is now accepted and ready to land.Nov 16 2015, 6:56 AM
This revision was automatically updated to reflect the committed changes.