1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; An integer truncation to i1 should be done with an and instruction to make
3 ; sure only the LSBit survives. Test that this is the case both for a returned
4 ; value and as the operand of a branch.
5 ; RUN: llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s
7 define zeroext i1 @test1(i32 %X) nounwind {
10 ; CHECK-NEXT: movzbl {{[0-9]+}}(%esp), %eax
11 ; CHECK-NEXT: andb $1, %al
13 %Y = trunc i32 %X to i1
17 define i1 @test2(i32 %val, i32 %mask) nounwind {
19 ; CHECK: # %bb.0: # %entry
20 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
21 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
22 ; CHECK-NEXT: btl %ecx, %eax
23 ; CHECK-NEXT: jae .LBB1_2
24 ; CHECK-NEXT: # %bb.1: # %ret_true
25 ; CHECK-NEXT: movb $1, %al
27 ; CHECK-NEXT: .LBB1_2: # %ret_false
28 ; CHECK-NEXT: xorl %eax, %eax
31 %shifted = ashr i32 %val, %mask
32 %anded = and i32 %shifted, 1
33 %trunced = trunc i32 %anded to i1
34 br i1 %trunced, label %ret_true, label %ret_false
41 define i32 @test3(ptr %ptr) nounwind {
44 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
45 ; CHECK-NEXT: testb $1, (%eax)
46 ; CHECK-NEXT: je .LBB2_2
47 ; CHECK-NEXT: # %bb.1: # %cond_true
48 ; CHECK-NEXT: movl $21, %eax
50 ; CHECK-NEXT: .LBB2_2: # %cond_false
51 ; CHECK-NEXT: movl $42, %eax
53 %val = load i8, ptr %ptr
54 %tmp = trunc i8 %val to i1
55 br i1 %tmp, label %cond_true, label %cond_false
62 define i32 @test4(ptr %ptr) nounwind {
65 ; CHECK-NEXT: testb $1, {{[0-9]+}}(%esp)
66 ; CHECK-NEXT: je .LBB3_2
67 ; CHECK-NEXT: # %bb.1: # %cond_true
68 ; CHECK-NEXT: movl $21, %eax
70 ; CHECK-NEXT: .LBB3_2: # %cond_false
71 ; CHECK-NEXT: movl $42, %eax
73 %tmp = ptrtoint ptr %ptr to i1
74 br i1 %tmp, label %cond_true, label %cond_false
81 define i32 @test5(double %d) nounwind {
84 ; CHECK-NEXT: subl $8, %esp
85 ; CHECK-NEXT: fldl {{[0-9]+}}(%esp)
86 ; CHECK-NEXT: fnstcw {{[0-9]+}}(%esp)
87 ; CHECK-NEXT: movzwl {{[0-9]+}}(%esp), %eax
88 ; CHECK-NEXT: orl $3072, %eax # imm = 0xC00
89 ; CHECK-NEXT: movw %ax, {{[0-9]+}}(%esp)
90 ; CHECK-NEXT: fldcw {{[0-9]+}}(%esp)
91 ; CHECK-NEXT: fistps {{[0-9]+}}(%esp)
92 ; CHECK-NEXT: fldcw {{[0-9]+}}(%esp)
93 ; CHECK-NEXT: testb $1, {{[0-9]+}}(%esp)
94 ; CHECK-NEXT: je .LBB4_2
95 ; CHECK-NEXT: # %bb.1: # %cond_true
96 ; CHECK-NEXT: movl $21, %eax
97 ; CHECK-NEXT: addl $8, %esp
99 ; CHECK-NEXT: .LBB4_2: # %cond_false
100 ; CHECK-NEXT: movl $42, %eax
101 ; CHECK-NEXT: addl $8, %esp
103 %tmp = fptosi double %d to i1
104 br i1 %tmp, label %cond_true, label %cond_false