summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/memset-2.ll
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-01-02 19:44:58 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-01-02 19:44:58 +0000
commit8c06aa1c597bb5c2c264a190bc35836f0a7b4cd5 (patch)
treeef29be4c79e78710d9b1b838d786df1cbf723a46 /test/CodeGen/X86/memset-2.ll
parent3458534f11417e0269401346e98331a9282c8573 (diff)
downloadllvm-8c06aa1c597bb5c2c264a190bc35836f0a7b4cd5.tar.gz
llvm-8c06aa1c597bb5c2c264a190bc35836f0a7b4cd5.tar.bz2
llvm-8c06aa1c597bb5c2c264a190bc35836f0a7b4cd5.tar.xz
Lower the i8 extension in memset to a multiply instead of a potentially long series of shifts and ors.
We could implement a DAGCombine to turn x * 0x0101 back into logic operations on targets that doesn't support the multiply or it is slow (p4) if someone cares enough. Example code: void test(char *s, int a) { __builtin_memset(s, a, 4); } before: _test: ## @test movzbl 8(%esp), %eax movl %eax, %ecx shll $8, %ecx orl %eax, %ecx movl %ecx, %eax shll $16, %eax orl %ecx, %eax movl 4(%esp), %ecx movl %eax, 4(%ecx) movl %eax, (%ecx) ret after: _test: ## @test movzbl 8(%esp), %eax imull $16843009, %eax, %eax ## imm = 0x1010101 movl 4(%esp), %ecx movl %eax, 4(%ecx) movl %eax, (%ecx) ret git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/memset-2.ll')
-rw-r--r--test/CodeGen/X86/memset-2.ll11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/CodeGen/X86/memset-2.ll b/test/CodeGen/X86/memset-2.ll
index 692965f6f7..11f619cd6d 100644
--- a/test/CodeGen/X86/memset-2.ll
+++ b/test/CodeGen/X86/memset-2.ll
@@ -17,3 +17,14 @@ entry:
call void @llvm.memset.i32( i8* undef, i8 %c, i32 76, i32 1 ) nounwind
unreachable
}
+
+declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
+
+define void @t3(i8* nocapture %s, i8 %a) nounwind {
+entry:
+ tail call void @llvm.memset.p0i8.i32(i8* %s, i8 %a, i32 8, i32 1, i1 false)
+ ret void
+; CHECK: t3:
+; CHECK: imull $16843009
+}
+