This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Implement isSExtCheaperThanZExt
ClosedPublic

Authored by hev on Jul 10 2023, 10:39 PM.

Details

Summary

Implement isSExtCheaperThanZExt.

Signed-off-by: WANG Rui <wangrui@loongson.cn>

Diff Detail

Event Timeline

hev created this revision.Jul 10 2023, 10:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 10:39 PM
hev requested review of this revision.Jul 10 2023, 10:39 PM
hev added inline comments.Jul 10 2023, 10:43 PM
llvm/test/CodeGen/LoongArch/ir-instruction/br.ll
29–30

Future patches will utilize the W instruction, thereby eliminating unnecessary sign extensions.

xen0n added inline comments.Jul 19 2023, 11:53 PM
llvm/test/CodeGen/LoongArch/ir-instruction/br.ll
29–30

Mind explaining a bit what's the codegen you intended? Right now I couldn't think of a *.w instruction that would allow us to reduce this basic block any further.

hev added a comment.Jul 20 2023, 3:38 AM

Thanks.

llvm/test/CodeGen/LoongArch/atomicrmw-uinc-udec-wrap.ll
308

Here. This sign extension instruction should be removed.

llvm/test/CodeGen/LoongArch/ir-instruction/br.ll
29–30

Uh, I posted my comments in the wrong place... It was supposed to appear in the place I marked above.

xen0n added inline comments.Jul 20 2023, 3:56 AM
llvm/test/CodeGen/LoongArch/atomicrmw-uinc-udec-wrap.ll
308

Okay. To be sure no one is forgetting about this you could add a note like "TODO: Optimize away the redundant sign extension before the atomicrmw loop" above the function, but if you're following up with a patch shortly it may be better to not do this (for less churn).

SixWeining accepted this revision.Jul 24 2023, 3:04 AM
This revision is now accepted and ready to land.Jul 24 2023, 3:04 AM
This revision was landed with ongoing or failed builds.Jul 24 2023, 6:46 PM
This revision was automatically updated to reflect the committed changes.