mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
For completeness, generalize the (X + Y) - Y -> X transform and add X - (X + 1) -> -1.
These were not recommended by my auto-simplifier since they don't fire often enough. However they do fire from time to time, for example they remove one subtraction from the final bitcode for 483.xalancbmk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123755 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -70,3 +70,23 @@ define i32 @sub1(i32 %x, i32 %y) {
|
||||
ret i32 %r
|
||||
; CHECK: ret i32 %y
|
||||
}
|
||||
|
||||
define i32 @sub2(i32 %x) {
|
||||
; CHECK: @sub2
|
||||
; X - (X + 1) -> -1
|
||||
%xp1 = add i32 %x, 1
|
||||
%r = sub i32 %x, %xp1
|
||||
ret i32 %r
|
||||
; CHECK: ret i32 -1
|
||||
}
|
||||
|
||||
define i32 @sub3(i32 %x, i32 %y) {
|
||||
; CHECK: @sub3
|
||||
; ((X + 1) + Y) - (Y + 1) -> X
|
||||
%xp1 = add i32 %x, 1
|
||||
%lhs = add i32 %xp1, %y
|
||||
%rhs = add i32 %y, 1
|
||||
%r = sub i32 %lhs, %rhs
|
||||
ret i32 %r
|
||||
; CHECK: ret i32 %x
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user