From 1c10b8de46ce8e39178eeded4786b1e53722f099 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 17 Mar 2011 20:39:14 +0000 Subject: BuildUDIV: If the divisor is even we can simplify the fixup of the multiplied value by introducing an early shift. This allows us to compile "unsigned foo(unsigned x) { return x/28; }" into shrl $2, %edi imulq $613566757, %rdi, %rax shrq $32, %rax ret instead of movl %edi, %eax imulq $613566757, %rax, %rcx shrq $32, %rcx subl %ecx, %eax shrl %eax addl %ecx, %eax shrl $4, %eax on x86_64 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127829 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/X86/divide-by-constant.ll | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/CodeGen/X86/divide-by-constant.ll b/test/CodeGen/X86/divide-by-constant.ll index fe335b9369..08e3272a37 100644 --- a/test/CodeGen/X86/divide-by-constant.ll +++ b/test/CodeGen/X86/divide-by-constant.ll @@ -60,3 +60,14 @@ entry: ; CHECK: shrl $31, %ecx ; CHECK: sarl $18, %eax } + +define i32 @test7(i32 %x) nounwind { + %div = udiv i32 %x, 28 + ret i32 %div +; CHECK: test7: +; CHECK: shrl $2 +; CHECK: movl $613566757 +; CHECK: mull +; CHECK-NOT: shrl +; CHECK: ret +} -- cgit v1.2.3