1*f4a2713aSLionel Sambuc; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s 2*f4a2713aSLionel Sambuc; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc; Reuse the flags value from the add instructions instead of emitting separate 5*f4a2713aSLionel Sambuc; testl instructions. 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc; Use the flags on the add. 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc; CHECK-LABEL: test1: 10*f4a2713aSLionel Sambuc; CHECK: addl 11*f4a2713aSLionel Sambuc; CHECK-NOT: test 12*f4a2713aSLionel Sambuc; CHECK: cmovnsl 13*f4a2713aSLionel Sambuc; CHECK: ret 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambucdefine i32 @test1(i32* %x, i32 %y, i32 %a, i32 %b) nounwind { 16*f4a2713aSLionel Sambuc %tmp2 = load i32* %x, align 4 ; <i32> [#uses=1] 17*f4a2713aSLionel Sambuc %tmp4 = add i32 %tmp2, %y ; <i32> [#uses=1] 18*f4a2713aSLionel Sambuc %tmp5 = icmp slt i32 %tmp4, 0 ; <i1> [#uses=1] 19*f4a2713aSLionel Sambuc %tmp.0 = select i1 %tmp5, i32 %a, i32 %b ; <i32> [#uses=1] 20*f4a2713aSLionel Sambuc ret i32 %tmp.0 21*f4a2713aSLionel Sambuc} 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambucdeclare void @foo(i32) 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc; Don't use the flags result of the and here, since the and has no 26*f4a2713aSLionel Sambuc; other use. A simple test is better. 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc; CHECK-LABEL: test2: 29*f4a2713aSLionel Sambuc; CHECK: testb $16, {{%dil|%cl}} 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambucdefine void @test2(i32 %x) nounwind { 32*f4a2713aSLionel Sambuc %y = and i32 %x, 16 33*f4a2713aSLionel Sambuc %t = icmp eq i32 %y, 0 34*f4a2713aSLionel Sambuc br i1 %t, label %true, label %false 35*f4a2713aSLionel Sambuctrue: 36*f4a2713aSLionel Sambuc call void @foo(i32 %x) 37*f4a2713aSLionel Sambuc ret void 38*f4a2713aSLionel Sambucfalse: 39*f4a2713aSLionel Sambuc ret void 40*f4a2713aSLionel Sambuc} 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc; Do use the flags result of the and here, since the and has another use. 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc; CHECK-LABEL: test3: 45*f4a2713aSLionel Sambuc; CHECK: andl $16, %e 46*f4a2713aSLionel Sambuc; CHECK-NEXT: jne 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambucdefine void @test3(i32 %x) nounwind { 49*f4a2713aSLionel Sambuc %y = and i32 %x, 16 50*f4a2713aSLionel Sambuc %t = icmp eq i32 %y, 0 51*f4a2713aSLionel Sambuc br i1 %t, label %true, label %false 52*f4a2713aSLionel Sambuctrue: 53*f4a2713aSLionel Sambuc call void @foo(i32 %y) 54*f4a2713aSLionel Sambuc ret void 55*f4a2713aSLionel Sambucfalse: 56*f4a2713aSLionel Sambuc ret void 57*f4a2713aSLionel Sambuc} 58