Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Enable machine copy propagation for copy-like instructions
Like what has been done in AArch64 (D125335). We enable this under `-O2` to show the codegen diffs here but we may only do this under `-O3` like AArch64. There are two cases that we may produce these eliminable copies: 1. ISel of `FrameIndex`. Like `rvv/fixed-vectors-calling-conv.ll`. 2. Tail duplication. Like `select-optimize-multiple.ll`. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D144535
- Loading branch information
1 parent
3b1240e
commit 5fdab3c
Showing
13 changed files
with
103 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc < %s -O3 -mtriple=riscv64 -riscv-enable-copy-propagation=false | FileCheck %s --check-prefix=NOPROP | ||
; RUN: llc < %s -O3 -mtriple=riscv64 -riscv-enable-copy-propagation=true | FileCheck %s --check-prefix=PROP | ||
|
||
define void @copyprop_after_mbp(i32 %v, i32* %a, i32* %b, i32* %c, i32* %d) { | ||
; NOPROP-LABEL: copyprop_after_mbp: | ||
; NOPROP: # %bb.0: | ||
; NOPROP-NEXT: sext.w a0, a0 | ||
; NOPROP-NEXT: li a5, 10 | ||
; NOPROP-NEXT: bne a0, a5, .LBB0_2 | ||
; NOPROP-NEXT: # %bb.1: # %bb.0 | ||
; NOPROP-NEXT: li a0, 15 | ||
; NOPROP-NEXT: sw a0, 0(a2) | ||
; NOPROP-NEXT: li a0, 1 | ||
; NOPROP-NEXT: sw a0, 0(a1) | ||
; NOPROP-NEXT: li a0, 12 | ||
; NOPROP-NEXT: sw a0, 0(a4) | ||
; NOPROP-NEXT: ret | ||
; NOPROP-NEXT: .LBB0_2: # %bb.1 | ||
; NOPROP-NEXT: li a0, 0 | ||
; NOPROP-NEXT: li a2, 25 | ||
; NOPROP-NEXT: sw a2, 0(a3) | ||
; NOPROP-NEXT: sw a0, 0(a1) | ||
; NOPROP-NEXT: li a0, 12 | ||
; NOPROP-NEXT: sw a0, 0(a4) | ||
; NOPROP-NEXT: ret | ||
; | ||
; PROP-LABEL: copyprop_after_mbp: | ||
; PROP: # %bb.0: | ||
; PROP-NEXT: sext.w a0, a0 | ||
; PROP-NEXT: li a5, 10 | ||
; PROP-NEXT: bne a0, a5, .LBB0_2 | ||
; PROP-NEXT: # %bb.1: # %bb.0 | ||
; PROP-NEXT: li a0, 15 | ||
; PROP-NEXT: sw a0, 0(a2) | ||
; PROP-NEXT: li a0, 1 | ||
; PROP-NEXT: sw a0, 0(a1) | ||
; PROP-NEXT: li a0, 12 | ||
; PROP-NEXT: sw a0, 0(a4) | ||
; PROP-NEXT: ret | ||
; PROP-NEXT: .LBB0_2: # %bb.1 | ||
; PROP-NEXT: li a2, 25 | ||
; PROP-NEXT: sw a2, 0(a3) | ||
; PROP-NEXT: sw zero, 0(a1) | ||
; PROP-NEXT: li a0, 12 | ||
; PROP-NEXT: sw a0, 0(a4) | ||
; PROP-NEXT: ret | ||
%1 = icmp eq i32 %v, 10 | ||
br i1 %1, label %bb.0, label %bb.1 | ||
|
||
bb.0: | ||
store i32 15, i32* %b, align 4 | ||
br label %bb.2 | ||
|
||
bb.1: | ||
store i32 25, i32* %c, align 4 | ||
br label %bb.2 | ||
|
||
bb.2: | ||
%2 = phi i32 [ 1, %bb.0 ], [ 0, %bb.1 ] | ||
store i32 %2, i32* %a, align 4 | ||
store i32 12, i32* %d, align 4 | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters