forked from anza-xyz/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Following the alterations made in solana-labs/rbpf#489, this PR removes the neg instructions and changes the semantics of sub when one of the operands is an immediate. sub r1, 2 now means r1 = 2 - r1, instead of r1 = r1 - 2. neg r1 is represented as r1 = 0 - r1. This is the second task in solana-labs/solana#34250.
- Loading branch information
Showing
4 changed files
with
125 additions
and
10 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
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,79 @@ | ||
; RUN: llc < %s -march=sbf -mattr=+alu32 | FileCheck --check-prefix=CHECK-v1 %s | ||
; RUN: llc < %s -march=sbf -mattr=+alu32 -mcpu=sbfv2 | FileCheck --check-prefix=CHECK-v2 %s | ||
|
||
|
||
; Function Attrs: norecurse nounwind readnone | ||
define dso_local i64 @sub_imm_minus_reg_64(i64 %a) #0 { | ||
entry: | ||
; CHECK-LABEL: sub_imm_minus_reg_64: | ||
%sub = sub nsw i64 50, %a | ||
|
||
; CHECK-v1: mov64 r{{[0-9]+}}, 50 | ||
; CHECK-v1: sub64 r{{[0-9]+}}, r{{[0-9]+}} | ||
|
||
; CHECK-v2: sub64 r{{[0-9]+}}, 50 | ||
ret i64 %sub | ||
} | ||
|
||
; Function Attrs: norecurse nounwind readnone | ||
define dso_local i64 @sub_reg_minus_imm_64(i64 %a) #0 { | ||
entry: | ||
; CHECK-LABEL: sub_reg_minus_imm_64: | ||
%t = sub nsw i64 %a, 50 | ||
; CHECK-v1: add64 r{{[0-9]+}}, -50 | ||
|
||
; CHECK-v2: add64 r{{[0-9]+}}, -50 | ||
ret i64 %t | ||
} | ||
|
||
|
||
; Function Attrs: norecurse nounwind readnone | ||
define dso_local i32 @sub_imm_minus_reg_32(i32 %a) #0 { | ||
entry: | ||
; CHECK-LABEL: sub_imm_minus_reg_32: | ||
%sub = sub nsw i32 50, %a | ||
|
||
; CHECK-v1: mov32 w{{[0-9]+}}, 50 | ||
; CHECK-v1: sub32 w{{[0-9]+}}, w{{[0-9]+}} | ||
|
||
; CHECK-v2: sub32 w{{[0-9]+}}, 50 | ||
|
||
ret i32 %sub | ||
} | ||
|
||
; Function Attrs: norecurse nounwind readnone | ||
define dso_local i32 @sub_reg_minus_imm_32(i32 %a) #0 { | ||
entry: | ||
; CHECK-LABEL: sub_reg_minus_imm_32: | ||
%t = sub nsw i32 %a, 50 | ||
|
||
; CHECK-v1: add32 w{{[0-9]+}}, -50 | ||
|
||
; CHECK-v2: add32 w{{[0-9]+}}, -50 | ||
ret i32 %t | ||
} | ||
|
||
|
||
; Function Attrs: norecurse nounwind readnone | ||
define dso_local i64 @neg_64(i64 %a) #0 { | ||
entry: | ||
; CHECK-LABEL: neg_64: | ||
%sub = sub nsw i64 0, %a | ||
|
||
; CHECK-v1: neg64 r{{[0-9]+}} | ||
; CHECK-v2: sub64 r{{[0-9]+}}, 0 | ||
|
||
ret i64 %sub | ||
} | ||
|
||
; Function Attrs: norecurse nounwind readnone | ||
define dso_local i32 @neg_32(i32 %a) #0 { | ||
entry: | ||
; CHECK-LABEL: neg_32: | ||
%sub = sub nsw i32 0, %a | ||
|
||
; CHECK-v1: neg32 w{{[0-9]+}} | ||
; CHECK-v2: sub32 w{{[0-9]+}}, 0 | ||
|
||
ret i32 %sub | ||
} |