mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Teach DAGCombine to fold fold (sra (trunc (sr x, c1)), c2) -> (trunc (sra x, c1+c2) when c1 equals the amount of bits that are truncated off.
This happens all the time when a smul is promoted to a larger type.
On x86-64 we now compile "int test(int x) { return x/10; }" into
movslq %edi, %rax
imulq $1717986919, %rax, %rax
movq %rax, %rcx
shrq $63, %rcx
sarq $34, %rax <- used to be "shrq $32, %rax; sarl $2, %eax"
addl %ecx, %eax
This fires 96 times in gcc.c on x86-64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -51,3 +51,12 @@ define i32 @test5(i32 %A) nounwind {
|
||||
; CHECK: mull 4(%esp)
|
||||
}
|
||||
|
||||
define signext i16 @test6(i16 signext %x) nounwind {
|
||||
entry:
|
||||
%div = sdiv i16 %x, 10
|
||||
ret i16 %div
|
||||
; CHECK: test6:
|
||||
; CHECK: imull $26215, %eax, %eax
|
||||
; CHECK: shrl $31, %ecx
|
||||
; CHECK: sarl $18, %eax
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user