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