blob: 97db1b340e81c230d63d73ca967093367d28e6ae [file] [log] [blame]
Dan Gohmanb75e8642010-01-04 20:53:54 +00001; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002; rdar://5752025
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003
Dan Gohmanb75e8642010-01-04 20:53:54 +00004; We want:
Andrew Trick12f0dc62011-04-14 05:15:06 +00005; CHECK: movl $42, %ecx
6; CHECK-NEXT: movl 4(%esp), %eax
7; CHECK-NEXT: andl $15, %eax
8; CHECK-NEXT: cmovnel %ecx, %eax
Dan Gohmanb75e8642010-01-04 20:53:54 +00009; CHECK-NEXT: ret
10;
11; We don't want:
12; movl 4(%esp), %eax
13; movl %eax, %ecx # bad: extra copy
14; andl $15, %ecx
15; testl $15, %eax # bad: peep obstructed
Chris Lattnerce2bcc82008-02-19 17:37:35 +000016; movl $42, %eax
Dan Gohmanb75e8642010-01-04 20:53:54 +000017; cmovel %ecx, %eax
Chris Lattnerce2bcc82008-02-19 17:37:35 +000018; ret
19;
Dan Gohmanb75e8642010-01-04 20:53:54 +000020; We also don't want:
21; movl $15, %ecx # bad: larger encoding
22; andl 4(%esp), %ecx
Chris Lattnerce2bcc82008-02-19 17:37:35 +000023; movl $42, %eax
Dan Gohmanb75e8642010-01-04 20:53:54 +000024; cmovel %ecx, %eax
25; ret
26;
27; We also don't want:
28; movl 4(%esp), %ecx
29; andl $15, %ecx
30; testl %ecx, %ecx # bad: unnecessary test
31; movl $42, %eax
32; cmovel %ecx, %eax
Chris Lattnerce2bcc82008-02-19 17:37:35 +000033; ret
34
35define i32 @t1(i32 %X) nounwind {
36entry:
37 %tmp2 = and i32 %X, 15 ; <i32> [#uses=2]
38 %tmp4 = icmp eq i32 %tmp2, 0 ; <i1> [#uses=1]
39 %retval = select i1 %tmp4, i32 %tmp2, i32 42 ; <i32> [#uses=1]
40 ret i32 %retval
41}
42