According to my auto-simplifier the most common missed simplifications in

optimized code are:
  (non-negative number)+(power-of-two) != 0 -> true
and
  (x | 1) != 0 -> true
Instcombine knows about the second one of course, but only does it if X|1
has only one use.  These fire thousands of times in the testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124183 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2011-01-25 09:38:29 +00:00
parent b38824f866
commit d70d1a5c44
4 changed files with 299 additions and 13 deletions

View File

@@ -27,6 +27,14 @@ define i1 @zext2(i1 %x) {
; CHECK: ret i1 %x
}
define i1 @zext3() {
; CHECK: @zext3
%e = zext i1 1 to i32
%c = icmp ne i32 %e, 0
ret i1 %c
; CHECK: ret i1 true
}
define i1 @sext(i32 %x) {
; CHECK: @sext
%e1 = sext i32 %x to i64
@@ -43,3 +51,49 @@ define i1 @sext2(i1 %x) {
ret i1 %c
; CHECK: ret i1 %x
}
define i1 @sext3() {
; CHECK: @sext3
%e = sext i1 1 to i32
%c = icmp ne i32 %e, 0
ret i1 %c
; CHECK: ret i1 true
}
define i1 @add(i32 %x, i32 %y) {
; CHECK: @add
%l = lshr i32 %x, 1
%r = lshr i32 %y, 1
%s = add i32 %l, %r
%c = icmp eq i32 %s, 0
ret i1 %c
; CHECK: ret i1 false
}
define i1 @add2(i8 %x, i8 %y) {
; CHECK: @add2
%l = or i8 %x, 128
%r = or i8 %y, 129
%s = add i8 %l, %r
%c = icmp eq i8 %s, 0
ret i1 %c
; CHECK: ret i1 false
}
define i1 @addpowtwo(i32 %x, i32 %y) {
; CHECK: @addpowtwo
%l = lshr i32 %x, 1
%r = shl i32 1, %y
%s = add i32 %l, %r
%c = icmp eq i32 %s, 0
ret i1 %c
; CHECK: ret i1 false
}
define i1 @or(i32 %x) {
; CHECK: @or
%o = or i32 %x, 1
%c = icmp eq i32 %o, 0
ret i1 %c
; CHECK: ret i1 false
}