Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86] Use "and $0" and "orl $-1" to store 0 and -1 when optimizing fo…
…r minsize 64-bit, 32-bit and 16-bit move-immediate instructions are 7, 6, and 5 bytes, respectively, whereas and/or with 8-bit immediate is only three bytes. Since these instructions imply an additional memory read (which the CPU could elide, but we don't think it does), restrict these patterns to minsize functions. Differential Revision: http://reviews.llvm.org/D18374 llvm-svn: 264440
- Loading branch information
Showing
3 changed files
with
101 additions
and
1 deletion.
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,88 @@ | ||
; RUN: llc -mtriple=i686-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=CHECK32 --check-prefix=CHECK | ||
; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=CHECK64 --check-prefix=CHECK | ||
|
||
define void @zero_optsize(i32* %p) optsize { | ||
entry: | ||
store i32 0, i32* %p | ||
ret void | ||
|
||
; CHECK-LABEL: zero_optsize: | ||
; CHECK: movl $0 | ||
; CHECK: ret | ||
} | ||
|
||
define void @minus_one_optsize(i32* %p) optsize { | ||
entry: | ||
store i32 -1, i32* %p | ||
ret void | ||
|
||
; CHECK-LABEL: minus_one_optsize: | ||
; CHECK: movl $-1 | ||
; CHECK: ret | ||
} | ||
|
||
|
||
define void @zero_64(i64* %p) minsize { | ||
entry: | ||
store i64 0, i64* %p | ||
ret void | ||
|
||
; CHECK-LABEL: zero_64: | ||
; CHECK32: andl $0 | ||
; CHECK32: andl $0 | ||
; CHECK64: andq $0 | ||
; CHECK: ret | ||
} | ||
|
||
define void @zero_32(i32* %p) minsize { | ||
entry: | ||
store i32 0, i32* %p | ||
ret void | ||
|
||
; CHECK-LABEL: zero_32: | ||
; CHECK: andl $0 | ||
; CHECK: ret | ||
} | ||
|
||
define void @zero_16(i16* %p) minsize { | ||
entry: | ||
store i16 0, i16* %p | ||
ret void | ||
|
||
; CHECK-LABEL: zero_16: | ||
; CHECK: andw $0 | ||
; CHECK: ret | ||
} | ||
|
||
|
||
define void @minus_one_64(i64* %p) minsize { | ||
entry: | ||
store i64 -1, i64* %p | ||
ret void | ||
|
||
; CHECK-LABEL: minus_one_64: | ||
; CHECK32: orl $-1 | ||
; CHECK32: orl $-1 | ||
; CHECK64: orq $-1 | ||
; CHECK: ret | ||
} | ||
|
||
define void @minus_one_32(i32* %p) minsize { | ||
entry: | ||
store i32 -1, i32* %p | ||
ret void | ||
|
||
; CHECK-LABEL: minus_one_32: | ||
; CHECK: orl $-1 | ||
; CHECK: ret | ||
} | ||
|
||
define void @minus_one_16(i16* %p) minsize { | ||
entry: | ||
store i16 -1, i16* %p | ||
ret void | ||
|
||
; CHECK-LABEL: minus_one_16: | ||
; CHECK: orw $-1 | ||
; CHECK: ret | ||
} |
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