llvm-6502/test/CodeGen/X86/trunc-to-bool.ll
Reid Spencer e16746d92d Alter these tests to ensure they match a "test $1, X" X86 instruction that
is now generated by the LLVM backend for "trunc to bool" instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31935 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-27 05:08:03 +00:00

33 lines
946 B
LLVM

; An integer truncation to bool should be done with an and instruction to make
; sure only the LSBit survives. Test that this is the case both for a returned
; value and as the operand of a branch.
; RUN: llvm-as < %s | llc -march=x86 &&
; RUN: llvm-as < %s | llc -march=x86 | grep '\(and\)\|\(test.*\$1\)' | wc -l | grep 3
bool %test1(int %X) {
%Y = trunc int %X to bool
ret bool %Y
}
bool %test2(int %val, int %mask) {
entry:
%mask = trunc int %mask to ubyte
%shifted = ashr int %val, ubyte %mask
%anded = and int %shifted, 1
%trunced = trunc int %anded to bool
br bool %trunced, label %ret_true, label %ret_false
ret_true:
ret bool true
ret_false:
ret bool false
}
int %test3(sbyte* %ptr) {
%val = load sbyte* %ptr
%tmp = trunc sbyte %val to bool ; %<bool> [#uses=1]
br bool %tmp, label %cond_true, label %cond_false
cond_true:
ret int 21
cond_false:
ret int 42
}