aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/X86/fold-imm.ll
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-11-27 00:49:46 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-11-27 00:49:46 +0000
commit884c70c912b699a4d14d05dcac1ac4f2d47c0f9a (patch)
treeeea845867e8c466b91a3bf184a9c9c1df7049e2e /test/CodeGen/X86/fold-imm.ll
parent56eca9103ecbf2293842bfd6067ac26629221eaf (diff)
downloadexternal_llvm-884c70c912b699a4d14d05dcac1ac4f2d47c0f9a.zip
external_llvm-884c70c912b699a4d14d05dcac1ac4f2d47c0f9a.tar.gz
external_llvm-884c70c912b699a4d14d05dcac1ac4f2d47c0f9a.tar.bz2
On x86 favors folding short immediate into some arithmetic operations (e.g. add, and, xor, etc.) because materializing an immediate in a register is expensive in turns of code size.
e.g. movl 4(%esp), %eax addl $4, %eax is 2 bytes shorter than movl $4, %eax addl 4(%esp), %eax git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60139 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/fold-imm.ll')
-rw-r--r--test/CodeGen/X86/fold-imm.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/CodeGen/X86/fold-imm.ll b/test/CodeGen/X86/fold-imm.ll
new file mode 100644
index 0000000..1623f31
--- /dev/null
+++ b/test/CodeGen/X86/fold-imm.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | llc -march=x86 | grep inc
+; RUN: llvm-as < %s | llc -march=x86 | grep add | grep 4
+
+define i32 @test(i32 %X) nounwind {
+entry:
+ %0 = add i32 %X, 1
+ ret i32 %0
+}
+
+define i32 @test2(i32 %X) nounwind {
+entry:
+ %0 = add i32 %X, 4
+ ret i32 %0
+}