This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Implement TargetLowering::isLegalAddressingMode() hook
ClosedPublic

Authored by gonglingqin on Jan 30 2023, 12:55 AM.

Details

Summary

Use the exact addressing mode information instead of the default to
make better use of offsets in instructions.

Diff Detail

Event Timeline

gonglingqin created this revision.Jan 30 2023, 12:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2023, 12:55 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
gonglingqin requested review of this revision.Jan 30 2023, 12:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2023, 12:55 AM
xen0n added inline comments.Jan 30 2023, 3:18 AM
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3181

Isn't k*r+r entirely expressible with alsl in case of k in (2, 4, 8, 16 if LA64)? You may want to implement it this time, but I'm fine either way.

xen0n added inline comments.Jan 30 2023, 3:29 AM
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3181

Hmm, I haven't dug any deeper but if this predicate only governs actions that end up with a ld/st then please ignore my comment.

gonglingqin added inline comments.Jan 30 2023, 3:51 AM
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3181

Thank you for your review! As explained in https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/TargetLowering.h#L2600-L2607, this predicate only governs actions that end up with a load/store.

xen0n accepted this revision.Jan 31 2023, 5:23 PM

LGTM with the nit addressed, thanks!

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3153–3155

nit: "reg + 14-bit signed offset left-shifted by 2" could be a lot more concise.

This revision is now accepted and ready to land.Jan 31 2023, 5:23 PM
gonglingqin added inline comments.Jan 31 2023, 6:19 PM
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3153–3155

Thanks! I will modify it.

Address xen0n's comments.

xen0n accepted this revision.Jan 31 2023, 7:58 PM