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 6 7define zeroext i1 @test1(i32 %X) nounwind { 8; CHECK-LABEL: test1: 9; CHECK: # %bb.0: 10; CHECK-NEXT: movb {{[0-9]+}}(%esp), %al 11; CHECK-NEXT: andb $1, %al 12; CHECK-NEXT: retl 13 %Y = trunc i32 %X to i1 14 ret i1 %Y 15} 16 17define i1 @test2(i32 %val, i32 %mask) nounwind { 18; CHECK-LABEL: test2: 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 26; CHECK-NEXT: retl 27; CHECK-NEXT: .LBB1_2: # %ret_false 28; CHECK-NEXT: xorl %eax, %eax 29; CHECK-NEXT: retl 30entry: 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 35ret_true: 36 ret i1 true 37ret_false: 38 ret i1 false 39} 40 41define i32 @test3(i8* %ptr) nounwind { 42; CHECK-LABEL: test3: 43; CHECK: # %bb.0: 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 49; CHECK-NEXT: retl 50; CHECK-NEXT: .LBB2_2: # %cond_false 51; CHECK-NEXT: movl $42, %eax 52; CHECK-NEXT: retl 53 %val = load i8, i8* %ptr 54 %tmp = trunc i8 %val to i1 55 br i1 %tmp, label %cond_true, label %cond_false 56cond_true: 57 ret i32 21 58cond_false: 59 ret i32 42 60} 61 62define i32 @test4(i8* %ptr) nounwind { 63; CHECK-LABEL: test4: 64; CHECK: # %bb.0: 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 69; CHECK-NEXT: retl 70; CHECK-NEXT: .LBB3_2: # %cond_false 71; CHECK-NEXT: movl $42, %eax 72; CHECK-NEXT: retl 73 %tmp = ptrtoint i8* %ptr to i1 74 br i1 %tmp, label %cond_true, label %cond_false 75cond_true: 76 ret i32 21 77cond_false: 78 ret i32 42 79} 80 81define i32 @test5(double %d) nounwind { 82; CHECK-LABEL: test5: 83; CHECK: # %bb.0: 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 98; CHECK-NEXT: retl 99; CHECK-NEXT: .LBB4_2: # %cond_false 100; CHECK-NEXT: movl $42, %eax 101; CHECK-NEXT: addl $8, %esp 102; CHECK-NEXT: retl 103 %tmp = fptosi double %d to i1 104 br i1 %tmp, label %cond_true, label %cond_false 105cond_true: 106 ret i32 21 107cond_false: 108 ret i32 42 109} 110