This is an archive of the discontinued LLVM Phabricator instance.

[AArch64 NEON] Add patterns for loading vector constant from constant poll.
ClosedPublic

Authored by kevin.qin on Dec 11 2013, 6:38 PM.

Details

Reviewers
t.p.northover
Summary

Hi,

In AArch64, most of loading constant from constant poll are implemented as:

adrp x0, .Label
ld x1, [x0, #.lo12.Label]

But for vector load LD1, it doesn't have pre-index format. So I have to choose one of the sequence below:

adrp x0, .Label
add x0, x0, #.lo12.Label
ld1 {x1}, [x0]

adr x0, .Label
ld1 {x1}, [x0]

I'm not quite familiar with ADRP and ADR, so I simply choose the second one as it has less instruction.
Please review, thanks.

Diff Detail

Event Timeline

Hi Kevin,

A single ADR is incorrect. The constants are in a separate section, which means they might be up to 4GB away from the code executing. It's no coincidence that this is precisely the distance an ADRP/ADD pair is capable of addressing (ADR can only do 2MB, I think).

That said, there's no particular reason for these to be NEON loads. On little-endian machines "ldr qD, [xN, :lo12:whatever]" (or "dD") does the same thing, and on big-endian machines (if anyone ever cares enough) we can change the constpool entry so that it still works. That's probably the most efficient way to handle it.

Cheers.

Tim

kevin.qin updated this revision to Unknown Object (????).Dec 16 2013, 1:24 AM

Use LDR instead. Please reivew. Thanks.

Hi Kevin,

Thanks for the updated version. It looks good, but reveals a couple more changes that should go in at the same time:

lib/Target/AArch64/AArch64ISelLowering.cpp
2305–2307

This means that the corresponding case in AArch64ISelDAGToDAG.cpp:1116 will never trigger. That's a *very* good thing, since your version is actually correct (I've no idea what I was thinking when I wrote that) but it should probably be removed.

Could you also modify the neon-mov.ll test to make sure this doesn't happen again (from current codegen, but should be fixed with your patch):

movi1d:                                 // @movi1d
    .cfi_startproc
    ldr	d0, [.LCPI40_0, #0]    // WTF???
    movi	 d1, #0xffffffff0000
    b	test_movi1d
kevin.qin updated this revision to Unknown Object (????).Dec 16 2013, 6:34 PM

Hi Tim,

Thanks for your review. Some changes on AArch64ISelDAGToDAG and neon-mov.ll followed your comments.

t.p.northover accepted this revision.Dec 17 2013, 3:06 AM

Looks good to me. Thanks for working on the revisions.

Cheers.

Tim.

Eugene.Zelenko closed this revision.Oct 4 2016, 4:31 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL197551.