Page MenuHomePhabricator

[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

Unit TestsFailed

TimeTest
60,090 msx64 debian > AddressSanitizer-x86_64-linux-dynamic.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/scariness_score_test.cpp.tmp
60,100 msx64 debian > LLVM.CodeGen/NVPTX::wmma.py
Script: -- : 'RUN: at line 5'; "/usr/bin/python3.9" /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/NVPTX/wmma.py --ptx=60 --gpu-arch=70 > /var/lib/buildkite-agent/builds/llvm-project/build/test/CodeGen/NVPTX/Output/wmma.py.tmp-ptx60-sm_70.ll
60,040 msx64 debian > MLIR.Examples/standalone::test.toy
Script: -- : 'RUN: at line 1'; /usr/bin/cmake /var/lib/buildkite-agent/builds/llvm-project/mlir/examples/standalone -G "Ninja" -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/var/lib/buildkite-agent/builds/llvm-project/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld

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.