llvm-6502/test/Transforms/InstCombine/sext-misc.ll
Chris Lattner 8114b718c9 make truncate/sext elimination capable of changing phi's. This
implements rdar://6013816 and the testcase in Transforms/InstCombine/sext-misc.ll.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52440 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-18 04:00:49 +00:00

66 lines
1.3 KiB
LLVM

; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sext
declare i32 @llvm.ctpop.i32(i32)
declare i32 @llvm.ctlz.i32(i32)
declare i32 @llvm.cttz.i32(i32)
define i64 @foo(i32 %x) {
%t = call i32 @llvm.ctpop.i32(i32 %x)
%s = sext i32 %t to i64
ret i64 %s
}
define i64 @boo(i32 %x) {
%t = call i32 @llvm.ctlz.i32(i32 %x)
%s = sext i32 %t to i64
ret i64 %s
}
define i64 @zoo(i32 %x) {
%t = call i32 @llvm.cttz.i32(i32 %x)
%s = sext i32 %t to i64
ret i64 %s
}
define i64 @coo(i32 %x) {
%t = udiv i32 %x, 3
%s = sext i32 %t to i64
ret i64 %s
}
define i64 @moo(i32 %x) {
%t = urem i32 %x, 30000
%s = sext i32 %t to i64
ret i64 %s
}
define i64 @yoo(i32 %x) {
%u = lshr i32 %x, 3
%t = mul i32 %u, 3
%s = sext i32 %t to i64
ret i64 %s
}
define i64 @voo(i32 %x) {
%t = and i32 %x, 511
%u = sub i32 20000, %t
%s = sext i32 %u to i64
ret i64 %s
}
define i32 @woo(i8 %a, i32 %f, i1 %p, i32* %z) {
%d = lshr i32 %f, 24
%e = select i1 %p, i32 %d, i32 0
%s = trunc i32 %e to i16
%n = sext i16 %s to i32
ret i32 %n
}
; rdar://6013816
define i16 @test(i16 %t, i1 %cond) nounwind {
entry:
br i1 %cond, label %T, label %F
T:
%t2 = sext i16 %t to i32
br label %F
F:
%V = phi i32 [%t2, %T], [42, %entry]
%W = trunc i32 %V to i16
ret i16 %W
}