Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions llvm/lib/CodeGen/MachineCopyPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,16 +937,6 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
if (CopyOperands) {
Register RegSrc = CopyOperands->Source->getReg();
Register RegDef = CopyOperands->Destination->getReg();
// It's possible that the previous transformations have resulted in a
// no-op register move (i.e. one where source and destination registers
// are the same and are not referring to a reserved register). If so,
// delete it.
if (RegSrc == RegDef && !MRI->isReserved(RegSrc)) {
MI.eraseFromParent();
NumDeletes++;
Changed = true;
continue;
}

if (!TRI->regsOverlap(RegDef, RegSrc)) {
// Copy is now a candidate for deletion.
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/RISCV/GlobalISel/constbarrier-rv32.ll
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ define void @constant_fold_barrier_i128(ptr %p) {
; RV32-NEXT: mv a6, a1
; RV32-NEXT: seqz a7, a1
; RV32-NEXT: and a1, a7, a1
; RV32-NEXT: mv a1, a1
; RV32-NEXT: mv a7, a1
; RV32-NEXT: seqz a3, a1
; RV32-NEXT: and a1, a3, a1
; RV32-NEXT: mv a1, a1
; RV32-NEXT: mv a1, a1
; RV32-NEXT: sw a2, 0(a0)
; RV32-NEXT: sw a6, 4(a0)
; RV32-NEXT: sw a7, 8(a0)
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/RISCV/GlobalISel/div-by-constant.ll
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,18 @@ define i64 @udiv64_constant_no_add(i64 %a) nounwind {
; RV32-NEXT: mulhu a1, a1, a2
; RV32-NEXT: add a5, a5, a6
; RV32-NEXT: mv t0, t1
; RV32-NEXT: mv a1, a1
; RV32-NEXT: sltu a4, a5, a6
; RV32-NEXT: add a5, a5, a7
; RV32-NEXT: sltu a6, t1, t1
; RV32-NEXT: sltiu t1, t1, 0
; RV32-NEXT: add t0, t0, t2
; RV32-NEXT: mv a1, a1
; RV32-NEXT: sltu a2, a5, a7
; RV32-NEXT: add a6, a6, t1
; RV32-NEXT: sltu a5, t0, t2
; RV32-NEXT: add t0, t0, a0
; RV32-NEXT: mv a1, a1
; RV32-NEXT: add a2, a4, a2
; RV32-NEXT: add a5, a6, a5
; RV32-NEXT: sltu a0, t0, a0
Expand Down Expand Up @@ -155,6 +158,7 @@ define i64 @udiv64_constant_add(i64 %a) nounwind {
; RV32-NEXT: mulhu a7, a0, a2
; RV32-NEXT: mulhu t2, a1, a3
; RV32-NEXT: mv t1, t2
; RV32-NEXT: mv t1, t1
; RV32-NEXT: mul t2, a1, a3
; RV32-NEXT: mulhu a2, a1, a2
; RV32-NEXT: mulhu a3, a0, a3
Expand Down
8 changes: 6 additions & 2 deletions llvm/test/CodeGen/RISCV/machine-copyprop-noop-removal.mir
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc -o - %s -mtriple=riscv64 -run-pass=machine-cp -mcp-use-is-copy-instr | FileCheck %s

## This test was added to capture a case where MachineCopyPropagation risks
## leaving a no-op register move (add, x0, reg).
## This test was added to capture a case where MachineCopyPropagation may
## leave a no-op register move (add reg, x0, reg).
## Due to the bug reported in
## <https://github.com/llvm/llvm-project/issues/166870>, we are not currently
## able to optimize this case.

---
name: ham
Expand All @@ -21,6 +24,7 @@ body: |
; CHECK-NEXT: liveins: $x10
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $x11 = ADDI $x0, 0
; CHECK-NEXT: renamable $x10 = ADDI killed renamable $x10, 0
; CHECK-NEXT: BEQ renamable $x10, $x0, %bb.4
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/RISCV/sextw-removal.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ define signext i32 @sextw_sh2add(i1 zeroext %0, ptr %1, i32 signext %2, i32 sign
; NOREMOVAL-LABEL: sextw_sh2add:
; NOREMOVAL: # %bb.0:
; NOREMOVAL-NEXT: sh2add a2, a2, a3
; NOREMOVAL-NEXT: mv a2, a2
; NOREMOVAL-NEXT: beqz a0, .LBB22_2
; NOREMOVAL-NEXT: # %bb.1:
; NOREMOVAL-NEXT: sw a2, 0(a1)
Expand Down