mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-24 23:19:03 +00:00
Simplify (X<<1)-X into X. According to my auto-simplier this is the most common missed
simplification in fully optimized code. It occurs sporadically in the testsuite, and many times in 403.gcc: the final bitcode has 131 fewer subtractions after this change. The reason that the multiplies are not eliminated is the same reason that instcombine did not catch this: they are used by other instructions (instcombine catches this with a more general transform which in general is only profitable if the operands have only one use). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123754 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -31,6 +31,26 @@ define i32 @factorize3(i32 %x, i32 %a, i32 %b) {
|
||||
; CHECK: ret i32 %r
|
||||
}
|
||||
|
||||
define i32 @factorize4(i32 %x, i32 %y) {
|
||||
; CHECK: @factorize4
|
||||
%sh = shl i32 %y, 1
|
||||
%ml = mul i32 %sh, %x
|
||||
%mr = mul i32 %x, %y
|
||||
%s = sub i32 %ml, %mr
|
||||
ret i32 %s
|
||||
; CHECK: ret i32 %mr
|
||||
}
|
||||
|
||||
define i32 @factorize5(i32 %x, i32 %y) {
|
||||
; CHECK: @factorize5
|
||||
%sh = mul i32 %y, 2
|
||||
%ml = mul i32 %sh, %x
|
||||
%mr = mul i32 %x, %y
|
||||
%s = sub i32 %ml, %mr
|
||||
ret i32 %s
|
||||
; CHECK: ret i32 %mr
|
||||
}
|
||||
|
||||
define i32 @expand(i32 %x) {
|
||||
; CHECK: @expand
|
||||
; ((X & 1) | 2) & 1 -> ((X & 1) & 1) | (2 & 1) -> (X & 1) | 0 -> X & 1
|
||||
|
||||
Reference in New Issue
Block a user