Dan Gohman | b75e864 | 2010-01-04 20:53:54 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s |
Chris Lattner | ce2bcc8 | 2008-02-19 17:37:35 +0000 | [diff] [blame] | 2 | ; rdar://5752025 |
Chris Lattner | ce2bcc8 | 2008-02-19 17:37:35 +0000 | [diff] [blame] | 3 | |
Dan Gohman | b75e864 | 2010-01-04 20:53:54 +0000 | [diff] [blame] | 4 | ; We want: |
Andrew Trick | 12f0dc6 | 2011-04-14 05:15:06 +0000 | [diff] [blame] | 5 | ; CHECK: movl $42, %ecx |
| 6 | ; CHECK-NEXT: movl 4(%esp), %eax |
| 7 | ; CHECK-NEXT: andl $15, %eax |
| 8 | ; CHECK-NEXT: cmovnel %ecx, %eax |
Dan Gohman | b75e864 | 2010-01-04 20:53:54 +0000 | [diff] [blame] | 9 | ; 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 Lattner | ce2bcc8 | 2008-02-19 17:37:35 +0000 | [diff] [blame] | 16 | ; movl $42, %eax |
Dan Gohman | b75e864 | 2010-01-04 20:53:54 +0000 | [diff] [blame] | 17 | ; cmovel %ecx, %eax |
Chris Lattner | ce2bcc8 | 2008-02-19 17:37:35 +0000 | [diff] [blame] | 18 | ; ret |
| 19 | ; |
Dan Gohman | b75e864 | 2010-01-04 20:53:54 +0000 | [diff] [blame] | 20 | ; We also don't want: |
| 21 | ; movl $15, %ecx # bad: larger encoding |
| 22 | ; andl 4(%esp), %ecx |
Chris Lattner | ce2bcc8 | 2008-02-19 17:37:35 +0000 | [diff] [blame] | 23 | ; movl $42, %eax |
Dan Gohman | b75e864 | 2010-01-04 20:53:54 +0000 | [diff] [blame] | 24 | ; 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 Lattner | ce2bcc8 | 2008-02-19 17:37:35 +0000 | [diff] [blame] | 33 | ; ret |
| 34 | |
| 35 | define i32 @t1(i32 %X) nounwind { |
| 36 | entry: |
| 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 | |