File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,20 @@ bool BranchRelaxation::fixupConditionalBranch(MachineInstr &MI) {
491491 return true ;
492492 }
493493 if (FBB) {
494+ // If we get here with a MBB which ends like this:
495+ //
496+ // bb.1:
497+ // successors: %bb.2;
498+ // ...
499+ // BNE $x1, $x0, %bb.2
500+ // PseudoBR %bb.2
501+ //
502+ // Just remove conditional branch.
503+ if (TBB == FBB) {
504+ BlockInfo[MBB->getNumber ()].Size -= TII->getInstSizeInBytes (MI);
505+ MI.eraseFromParent ();
506+ return true ;
507+ }
494508 // We need to split the basic block here to obtain two long-range
495509 // unconditional branches.
496510 NewBB = createNewBlockAfter (*MBB);
Original file line number Diff line number Diff line change 1+ # NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+ # RUN: llc %s -mtriple=riscv64 -run-pass=branch-relaxation -o - -verify-machineinstrs | FileCheck %s
3+
4+ --- |
5+ define void @foo() {
6+ ret void
7+ }
8+ ...
9+ ---
10+ name : foo
11+ tracksRegLiveness : true
12+ body : |
13+ bb.0:
14+ liveins: $x1
15+ BNE $x1, $x0, %bb.3
16+ PseudoBR %bb.3
17+ bb.1:
18+ liveins: $x1
19+ INLINEASM &".space 4096", 1
20+ BGE $x1, $x0, %bb.3
21+ bb.3:
22+ PseudoRET
23+ # # NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
24+ # CHECK: {{.*}}
You can’t perform that action at this time.
0 commit comments