llvm-6502/test/Transforms/InstCombine/sext-misc.ll
Dan Gohman 23e8b71526 Teach InstCombine's ComputeMaskedBits what SelectionDAG's
ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach
SelectionDAG's ComputeMaskedBits what InstCombine's knows
about SRem. And teach them both some things about high bits
in Mul, UDiv, URem, and Sub. This allows instcombine and
dagcombine to eliminate sign-extension operations in
several new cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50358 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-28 17:02:21 +00:00

46 lines
1001 B
LLVM

; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sext
; RUN: llvm-as < %s | llc -march=x86-64 | not grep movslq
; RUN: llvm-as < %s | llc -march=x86 | not grep sar
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
}