llvm-6502/test/Transforms/InstSimplify/2011-01-18-Compare.ll
Duncan Sands 9d32f60a6f At -O123 the early-cse pass is run before instcombine has run. According to my
auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0.
This patch adds this transform and some related logic to InstructionSimplify
and removes some of the logic from instcombine (unfortunately not all because
there are several situations in which instcombine can improve things by making
new instructions, whereas instsimplify is not allowed to do this).  At -O2 this
often results in more than 15% more simplifications by early-cse, and results in
hundreds of lines of bitcode being eliminated from the testsuite.  I did see some
small negative effects in the testsuite, for example a few additional instructions
in three programs.  One program, 483.xalancbmk, got an additional 35 instructions,
which seems to be due to a function getting an additional instruction and then
being inlined all over the place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123911 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 13:21:55 +00:00

46 lines
804 B
LLVM

; RUN: opt < %s -instsimplify -S | FileCheck %s
target datalayout = "p:32:32"
define i1 @ptrtoint() {
; CHECK: @ptrtoint
%a = alloca i8
%tmp = ptrtoint i8* %a to i32
%r = icmp eq i32 %tmp, 0
ret i1 %r
; CHECK: ret i1 false
}
define i1 @zext(i32 %x) {
; CHECK: @zext
%e1 = zext i32 %x to i64
%e2 = zext i32 %x to i64
%r = icmp eq i64 %e1, %e2
ret i1 %r
; CHECK: ret i1 true
}
define i1 @zext2(i1 %x) {
; CHECK: @zext2
%e = zext i1 %x to i32
%c = icmp ne i32 %e, 0
ret i1 %c
; CHECK: ret i1 %x
}
define i1 @sext(i32 %x) {
; CHECK: @sext
%e1 = sext i32 %x to i64
%e2 = sext i32 %x to i64
%r = icmp eq i64 %e1, %e2
ret i1 %r
; CHECK: ret i1 true
}
define i1 @sext2(i1 %x) {
; CHECK: @sext2
%e = sext i1 %x to i32
%c = icmp ne i32 %e, 0
ret i1 %c
; CHECK: ret i1 %x
}