Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PowerPC] Use subfic instruction for subtract from immediate
Provide a 64-bit pattern to use SUBFIC for subtracting from a 16-bit immediate. The corresponding pattern already exists for 32-bit integers. Committing on behalf of Hiroshi Inoue. Differential Revision: https://reviews.llvm.org/D29387 llvm-svn: 296144
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s | ||
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s | ||
|
||
; Make sure that the subfic is generated iff possible | ||
|
||
define i64 @subtract_from_imm1(i64 %v) nounwind readnone { | ||
entry: | ||
; CHECK-LABEL: subtract_from_imm1 | ||
; CHECK: subfic 3, 3, 32767 | ||
; CHECK: blr | ||
%sub = sub i64 32767, %v | ||
ret i64 %sub | ||
} | ||
|
||
define i64 @subtract_from_imm2(i64 %v) nounwind readnone { | ||
entry: | ||
; CHECK-LABEL: subtract_from_imm2 | ||
; CHECK-NOT: subfic | ||
; CHECK: blr | ||
%sub = sub i64 32768, %v | ||
ret i64 %sub | ||
} | ||
|
||
define i64 @subtract_from_imm3(i64 %v) nounwind readnone { | ||
entry: | ||
; CHECK-LABEL: subtract_from_imm3 | ||
; CHECK: subfic 3, 3, -32768 | ||
; CHECK: blr | ||
%sub = sub i64 -32768, %v | ||
ret i64 %sub | ||
} | ||
|
||
define i64 @subtract_from_imm4(i64 %v) nounwind readnone { | ||
entry: | ||
; CHECK-LABEL: subtract_from_imm4 | ||
; CHECK-NOT: subfic | ||
; CHECK: blr | ||
%sub = sub i64 -32769, %v | ||
ret i64 %sub | ||
} | ||
|