110 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; An integer truncation to i1 should be done with an and instruction to make3; sure only the LSBit survives. Test that this is the case both for a returned4; value and as the operand of a branch.5; RUN: llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s6 7define zeroext i1 @test1(i32 %X) nounwind {8; CHECK-LABEL: test1:9; CHECK: # %bb.0:10; CHECK-NEXT: movzbl {{[0-9]+}}(%esp), %eax11; CHECK-NEXT: andb $1, %al12; CHECK-NEXT: retl13 %Y = trunc i32 %X to i114 ret i1 %Y15}16 17define i1 @test2(i32 %val, i32 %mask) nounwind {18; CHECK-LABEL: test2:19; CHECK: # %bb.0: # %entry20; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax21; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx22; CHECK-NEXT: btl %ecx, %eax23; CHECK-NEXT: jae .LBB1_224; CHECK-NEXT: # %bb.1: # %ret_true25; CHECK-NEXT: movb $1, %al26; CHECK-NEXT: retl27; CHECK-NEXT: .LBB1_2: # %ret_false28; CHECK-NEXT: xorl %eax, %eax29; CHECK-NEXT: retl30entry:31 %shifted = ashr i32 %val, %mask32 %anded = and i32 %shifted, 133 %trunced = trunc i32 %anded to i134 br i1 %trunced, label %ret_true, label %ret_false35ret_true:36 ret i1 true37ret_false:38 ret i1 false39}40 41define i32 @test3(ptr %ptr) nounwind {42; CHECK-LABEL: test3:43; CHECK: # %bb.0:44; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax45; CHECK-NEXT: testb $1, (%eax)46; CHECK-NEXT: je .LBB2_247; CHECK-NEXT: # %bb.1: # %cond_true48; CHECK-NEXT: movl $21, %eax49; CHECK-NEXT: retl50; CHECK-NEXT: .LBB2_2: # %cond_false51; CHECK-NEXT: movl $42, %eax52; CHECK-NEXT: retl53 %val = load i8, ptr %ptr54 %tmp = trunc i8 %val to i155 br i1 %tmp, label %cond_true, label %cond_false56cond_true:57 ret i32 2158cond_false:59 ret i32 4260}61 62define i32 @test4(ptr %ptr) nounwind {63; CHECK-LABEL: test4:64; CHECK: # %bb.0:65; CHECK-NEXT: testb $1, {{[0-9]+}}(%esp)66; CHECK-NEXT: je .LBB3_267; CHECK-NEXT: # %bb.1: # %cond_true68; CHECK-NEXT: movl $21, %eax69; CHECK-NEXT: retl70; CHECK-NEXT: .LBB3_2: # %cond_false71; CHECK-NEXT: movl $42, %eax72; CHECK-NEXT: retl73 %tmp = ptrtoint ptr %ptr to i174 br i1 %tmp, label %cond_true, label %cond_false75cond_true:76 ret i32 2177cond_false:78 ret i32 4279}80 81define i32 @test5(double %d) nounwind {82; CHECK-LABEL: test5:83; CHECK: # %bb.0:84; CHECK-NEXT: subl $8, %esp85; CHECK-NEXT: fldl {{[0-9]+}}(%esp)86; CHECK-NEXT: fnstcw {{[0-9]+}}(%esp)87; CHECK-NEXT: movzwl {{[0-9]+}}(%esp), %eax88; CHECK-NEXT: orl $3072, %eax # imm = 0xC0089; 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_295; CHECK-NEXT: # %bb.1: # %cond_true96; CHECK-NEXT: movl $21, %eax97; CHECK-NEXT: addl $8, %esp98; CHECK-NEXT: retl99; CHECK-NEXT: .LBB4_2: # %cond_false100; CHECK-NEXT: movl $42, %eax101; CHECK-NEXT: addl $8, %esp102; CHECK-NEXT: retl103 %tmp = fptosi double %d to i1104 br i1 %tmp, label %cond_true, label %cond_false105cond_true:106 ret i32 21107cond_false:108 ret i32 42109}110