mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
Teach instruction simplify to use constant ranges to solve problems of the form
"icmp pred %X, CI" and a number of examples where "%X = binop %Y, CI2". Some of these cases (div and rem) used to make it through opt -O2, but the others are probably now making code elsewhere redundant (probably instcombine). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126988 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -137,22 +137,38 @@ define i1 @shl(i32 %x) {
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @lshr(i32 %x) {
|
||||
; CHECK: @lshr
|
||||
define i1 @lshr1(i32 %x) {
|
||||
; CHECK: @lshr1
|
||||
%s = lshr i32 -1, %x
|
||||
%c = icmp eq i32 %s, 0
|
||||
ret i1 %c
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @ashr(i32 %x) {
|
||||
; CHECK: @ashr
|
||||
define i1 @lshr2(i32 %x) {
|
||||
; CHECK: @lshr2
|
||||
%s = lshr i32 %x, 30
|
||||
%c = icmp ugt i32 %s, 8
|
||||
ret i1 %c
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @ashr1(i32 %x) {
|
||||
; CHECK: @ashr1
|
||||
%s = ashr i32 -1, %x
|
||||
%c = icmp eq i32 %s, 0
|
||||
ret i1 %c
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @ashr2(i32 %x) {
|
||||
; CHECK: @ashr2
|
||||
%s = ashr i32 %x, 30
|
||||
%c = icmp slt i32 %s, -5
|
||||
ret i1 %c
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @select1(i1 %cond) {
|
||||
; CHECK: @select1
|
||||
%s = select i1 %cond, i32 1, i32 0
|
||||
@@ -203,3 +219,59 @@ define i1 @urem2(i32 %X, i32 %Y) {
|
||||
ret i1 %B
|
||||
; CHECK ret i1 false
|
||||
}
|
||||
|
||||
define i1 @urem3(i32 %X) {
|
||||
; CHECK: @urem3
|
||||
%A = urem i32 %X, 10
|
||||
%B = icmp ult i32 %A, 15
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 true
|
||||
}
|
||||
|
||||
define i1 @urem4(i32 %X) {
|
||||
; CHECK: @urem4
|
||||
%A = urem i32 %X, 15
|
||||
%B = icmp ult i32 %A, 10
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 %B
|
||||
}
|
||||
|
||||
define i1 @srem1(i32 %X) {
|
||||
; CHECK: @srem1
|
||||
%A = srem i32 %X, -5
|
||||
%B = icmp sgt i32 %A, 5
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @udiv1(i32 %X) {
|
||||
; CHECK: @udiv1
|
||||
%A = udiv i32 %X, 1000000
|
||||
%B = icmp ult i32 %A, 5000
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 true
|
||||
}
|
||||
|
||||
define i1 @sdiv1(i32 %X) {
|
||||
; CHECK: @sdiv1
|
||||
%A = sdiv i32 %X, 1000000
|
||||
%B = icmp slt i32 %A, 3000
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 true
|
||||
}
|
||||
|
||||
define i1 @or1(i32 %X) {
|
||||
; CHECK: @or1
|
||||
%A = or i32 %X, 62
|
||||
%B = icmp ult i32 %A, 50
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
define i1 @and1(i32 %X) {
|
||||
; CHECK: @and1
|
||||
%A = and i32 %X, 62
|
||||
%B = icmp ugt i32 %A, 70
|
||||
ret i1 %B
|
||||
; CHECK: ret i1 false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user