Add a triple to switch.ll test.
[oota-llvm.git] / test / CodeGen / X86 / trunc-to-bool.ll
1 ; An integer truncation to i1 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: llc < %s -march=x86 | FileCheck %s
5
6 define zeroext i1 @test1(i32 %X)  nounwind {
7     %Y = trunc i32 %X to i1
8     ret i1 %Y
9 }
10 ; CHECK-LABEL: test1:
11 ; CHECK: andl $1, %eax
12
13 define i1 @test2(i32 %val, i32 %mask) nounwind {
14 entry:
15     %shifted = ashr i32 %val, %mask
16     %anded = and i32 %shifted, 1
17     %trunced = trunc i32 %anded to i1
18     br i1 %trunced, label %ret_true, label %ret_false
19 ret_true:
20     ret i1 true
21 ret_false:
22     ret i1 false
23 }
24 ; CHECK-LABEL: test2:
25 ; CHECK: btl
26
27 define i32 @test3(i8* %ptr) nounwind {
28     %val = load i8, i8* %ptr
29     %tmp = trunc i8 %val to i1
30     br i1 %tmp, label %cond_true, label %cond_false
31 cond_true:
32     ret i32 21
33 cond_false:
34     ret i32 42
35 }
36 ; CHECK-LABEL: test3:
37 ; CHECK: testb $1, (%eax)
38
39 define i32 @test4(i8* %ptr) nounwind {
40     %tmp = ptrtoint i8* %ptr to i1
41     br i1 %tmp, label %cond_true, label %cond_false
42 cond_true:
43     ret i32 21
44 cond_false:
45     ret i32 42
46 }
47 ; CHECK-LABEL: test4:
48 ; CHECK: testb $1, 4(%esp)
49
50 define i32 @test5(double %d) nounwind {
51     %tmp = fptosi double %d to i1
52     br i1 %tmp, label %cond_true, label %cond_false
53 cond_true:
54     ret i32 21
55 cond_false:
56     ret i32 42
57 }
58 ; CHECK-LABEL: test5:
59 ; CHECK: testb $1