diff --git a/llvm/test/CodeGen/RISCV/regcoal-constreg.mir b/llvm/test/CodeGen/RISCV/regcoal-constreg.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/regcoal-constreg.mir @@ -0,0 +1,67 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -mtriple=riscv32 -run-pass=simple-register-coalescing %s -o - -verify-coalescing | FileCheck %s +--- +name: f +registers: + - { id: 0, class: gpr } +body: | + ; CHECK-LABEL: name: f + ; CHECK: bb.0: + ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000) + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x0 + ; CHECK-NEXT: BEQ $x1, $x2, %bb.2 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: bb.1: + ; CHECK-NEXT: successors: %bb.2(0x80000000) + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: bb.2: + ; CHECK-NEXT: PseudoRET implicit [[COPY1]] + bb.0: + ; TODO: Both of these copies could be eliminated and the $x0 moved into + ; the PseudoRET + %0 = COPY $x0 + BEQ $x1, $x2, %bb.2 + + bb.1: + %0 = COPY $x0 + + bb.2: + PseudoRET implicit %0 + +... +--- +name: g +registers: + - { id: 0, class: gpr } +body: | + ; CHECK-LABEL: name: g + ; CHECK: bb.0: + ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000) + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x0 + ; CHECK-NEXT: BEQ $x1, $x2, %bb.2 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: bb.1: + ; CHECK-NEXT: successors: %bb.2(0x80000000) + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x0 + ; CHECK-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[ADDI]], 1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: bb.2: + ; CHECK-NEXT: PseudoRET implicit [[ADDI]] + bb.0: + %0 = COPY $x0 + BEQ $x1, $x2, %bb.2 + + bb.1: + ; TODO: This copy could be eliminated and the $x0 moved into ADDI + %0 = COPY $x0 + %0 = ADDI %0, 1 + + bb.2: + PseudoRET implicit %0 + +...