This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Add codegen support for conditional branches
ClosedPublic

Authored by wangleiat on Jun 23 2022, 5:10 AM.

Details

Summary

Setting ISD::BR_CC to Expand makes it much easier to deal with
matching the expanded form.

Depends on D128427

Diff Detail

Event Timeline

wangleiat created this revision.Jun 23 2022, 5:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 5:10 AM
wangleiat requested review of this revision.Jun 23 2022, 5:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 5:10 AM
wangleiat updated this revision to Diff 440103.Jun 26 2022, 8:44 PM

Update tests to use opaque pointers

xen0n added inline comments.Jul 1 2022, 10:56 AM
llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
195

Could you explain a bit on why this is needed? I can't easily understand this as the only change is on the "guard" of said definition but the dropped check seems too important to ignore. (Maybe because I haven't looked at LLVM source code as hard as you did.)

llvm/test/CodeGen/LoongArch/ir-instruction/br.ll
22

Why this redundant unconditional jump? Is it because optimization is not enabled or other reason?

wangleiat added inline comments.Jul 1 2022, 7:14 PM
llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
195

Sorry, I also do not understand.
I had to change simm26ls12, simm21ls12 and simm16lsl12_br to inherit from the Operand<OtherVT> class rather than Operand<GRLenVT> in order to keep tablegen happy.

wangleiat added inline comments.Jul 1 2022, 8:53 PM
llvm/test/CodeGen/LoongArch/ir-instruction/br.ll
22

We will implement overloading of the public function interface in later patches to eliminate unnecessary branches.
For example: TargetInstrInfo::analyzeBranch

xen0n accepted this revision.Jul 2 2022, 12:53 AM

Someone else more familiar with LLVM internals could teach us about that particular tblgen behavior noted above, but the rest LGTM.

llvm/test/CodeGen/LoongArch/ir-instruction/br.ll
22

Fair enough.

This revision is now accepted and ready to land.Jul 2 2022, 12:53 AM
SixWeining accepted this revision.Jul 4 2022, 9:01 PM
This revision was automatically updated to reflect the committed changes.