This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Implement prefetch locality by NTLH
ClosedPublic

Authored by BeMg on Jul 7 2023, 2:00 AM.

Details

Summary

We add the MemOperand then backend will generate NTLH automatically.

__builtin_prefetch(ptr,  0 /* rw==read */, 0 /* locality */); => ntl.all + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 1 /* locality */); => ntl.pall + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 2 /* locality */); => ntl.p1 + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 3 /* locality */); => prefetch.r (ptr)

Diff Detail

Event Timeline

BeMg created this revision.Jul 7 2023, 2:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 2:00 AM
BeMg requested review of this revision.Jul 7 2023, 2:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 2:00 AM
kito-cheng edited the summary of this revision. (Show Details)Jul 7 2023, 2:11 AM
BeMg updated this revision to Diff 538045.Jul 7 2023, 2:34 AM

rebase

fakepaper56 added inline comments.
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2126

Replace to Node->getConstantOperandVal(3)?

BeMg retitled this revision from [RISCV] Implemnt prefetch locality by NTLH to [RISCV] Implement prefetch locality by NTLH.Jul 11 2023, 7:57 PM
BeMg updated this revision to Diff 539360.Jul 11 2023, 8:05 PM

Use getConstantOperandVal

This revision is now accepted and ready to land.Jul 11 2023, 10:35 PM
asb added a comment.Jul 13 2023, 8:44 AM

I just mentioned this in https://github.com/riscv-non-isa/riscv-c-api-doc/pull/46, but given the NTL instructions are all just hints, perhaps we should be unconditionally emitting them even if zihintntl isn't known to be present (though printing it as add x0, x0, x? in .s form in that case). Not a blocker for landing this patch, but thought I'd mention.

This revision was automatically updated to reflect the committed changes.