1 ; An integer truncation to bool should be done with an and instruction to make
2 ; sure only the LSBit survives. Test that this is the case both for a returned
3 ; value and as the operand of a branch.
4 ; RUN: llvm-as < %s | llc -march=x86 &&
5 ; RUN: llvm-as < %s | llc -march=x86 | grep '\(and\)\|\(test.*\$1\)' | \
8 define bool %test1(i32 %X) zext {
9 %Y = trunc i32 %X to bool
13 define bool %test2(i32 %val, i32 %mask) {
15 %mask = trunc i32 %mask to i8
16 %shifted = ashr i32 %val, i8 %mask
17 %anded = and i32 %shifted, 1
18 %trunced = trunc i32 %anded to bool
19 br bool %trunced, label %ret_true, label %ret_false
26 define i32 %test3(i8* %ptr) {
28 %tmp = trunc i8 %val to bool
29 br bool %tmp, label %cond_true, label %cond_false
36 define i32 %test4(i8* %ptr) {
37 %tmp = ptrtoint i8* %ptr to bool
38 br bool %tmp, label %cond_true, label %cond_false
45 define i32 %test5(float %f) {
46 %tmp = fptoui float %f to bool
47 br bool %tmp, label %cond_true, label %cond_false
54 define i32 %test6(double %d) {
55 %tmp = fptosi double %d to bool
56 br bool %tmp, label %cond_true, label %cond_false