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