1*f4a2713aSLionel Sambuc; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s 2*f4a2713aSLionel Sambuc; rdar://5752025 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc; We want: 5*f4a2713aSLionel Sambuc; CHECK: movl 4(%esp), %ecx 6*f4a2713aSLionel Sambuc; CHECK-NEXT: andl $15, %ecx 7*f4a2713aSLionel Sambuc; CHECK-NEXT: movl $42, %eax 8*f4a2713aSLionel Sambuc; CHECK-NEXT: cmovel %ecx, %eax 9*f4a2713aSLionel Sambuc; CHECK-NEXT: ret 10*f4a2713aSLionel Sambuc; 11*f4a2713aSLionel Sambuc; We don't want: 12*f4a2713aSLionel Sambuc; movl 4(%esp), %eax 13*f4a2713aSLionel Sambuc; movl %eax, %ecx # bad: extra copy 14*f4a2713aSLionel Sambuc; andl $15, %ecx 15*f4a2713aSLionel Sambuc; testl $15, %eax # bad: peep obstructed 16*f4a2713aSLionel Sambuc; movl $42, %eax 17*f4a2713aSLionel Sambuc; cmovel %ecx, %eax 18*f4a2713aSLionel Sambuc; ret 19*f4a2713aSLionel Sambuc; 20*f4a2713aSLionel Sambuc; We also don't want: 21*f4a2713aSLionel Sambuc; movl $15, %ecx # bad: larger encoding 22*f4a2713aSLionel Sambuc; andl 4(%esp), %ecx 23*f4a2713aSLionel Sambuc; movl $42, %eax 24*f4a2713aSLionel Sambuc; cmovel %ecx, %eax 25*f4a2713aSLionel Sambuc; ret 26*f4a2713aSLionel Sambuc; 27*f4a2713aSLionel Sambuc; We also don't want: 28*f4a2713aSLionel Sambuc; movl 4(%esp), %ecx 29*f4a2713aSLionel Sambuc; andl $15, %ecx 30*f4a2713aSLionel Sambuc; testl %ecx, %ecx # bad: unnecessary test 31*f4a2713aSLionel Sambuc; movl $42, %eax 32*f4a2713aSLionel Sambuc; cmovel %ecx, %eax 33*f4a2713aSLionel Sambuc; ret 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambucdefine i32 @t1(i32 %X) nounwind { 36*f4a2713aSLionel Sambucentry: 37*f4a2713aSLionel Sambuc %tmp2 = and i32 %X, 15 ; <i32> [#uses=2] 38*f4a2713aSLionel Sambuc %tmp4 = icmp eq i32 %tmp2, 0 ; <i1> [#uses=1] 39*f4a2713aSLionel Sambuc %retval = select i1 %tmp4, i32 %tmp2, i32 42 ; <i32> [#uses=1] 40*f4a2713aSLionel Sambuc ret i32 %retval 41*f4a2713aSLionel Sambuc} 42