Chris Lattner | d37eaa3 | 2009-01-07 01:48:08 +0000 | [diff] [blame^] | 1 | ; RUN: llvm-as < %s | llc | grep {testl.*\(%r.i\), %} | count 3 |
| 2 | ; rdar://5671654 |
| 3 | ; The loads should fold into the testl instructions, no matter how |
| 4 | ; the inputs are commuted. |
| 5 | |
| 6 | target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" |
| 7 | target triple = "x86_64-apple-darwin7" |
| 8 | |
| 9 | define i32 @test(i32* %P, i32* %G) nounwind { |
| 10 | entry: |
| 11 | %0 = load i32* %P, align 4 ; <i32> [#uses=3] |
| 12 | %1 = load i32* %G, align 4 ; <i32> [#uses=1] |
| 13 | %2 = and i32 %1, %0 ; <i32> [#uses=1] |
| 14 | %3 = icmp eq i32 %2, 0 ; <i1> [#uses=1] |
| 15 | br i1 %3, label %bb1, label %bb |
| 16 | |
| 17 | bb: ; preds = %entry |
| 18 | %4 = tail call i32 @bar() nounwind ; <i32> [#uses=0] |
| 19 | ret i32 %0 |
| 20 | |
| 21 | bb1: ; preds = %entry |
| 22 | ret i32 %0 |
| 23 | } |
| 24 | |
| 25 | define i32 @test2(i32* %P, i32* %G) nounwind { |
| 26 | entry: |
| 27 | %0 = load i32* %P, align 4 ; <i32> [#uses=3] |
| 28 | %1 = load i32* %G, align 4 ; <i32> [#uses=1] |
| 29 | %2 = and i32 %0, %1 ; <i32> [#uses=1] |
| 30 | %3 = icmp eq i32 %2, 0 ; <i1> [#uses=1] |
| 31 | br i1 %3, label %bb1, label %bb |
| 32 | |
| 33 | bb: ; preds = %entry |
| 34 | %4 = tail call i32 @bar() nounwind ; <i32> [#uses=0] |
| 35 | ret i32 %0 |
| 36 | |
| 37 | bb1: ; preds = %entry |
| 38 | ret i32 %0 |
| 39 | } |
| 40 | define i32 @test3(i32* %P, i32* %G) nounwind { |
| 41 | entry: |
| 42 | %0 = load i32* %P, align 4 ; <i32> [#uses=3] |
| 43 | %1 = load i32* %G, align 4 ; <i32> [#uses=1] |
| 44 | %2 = and i32 %0, %1 ; <i32> [#uses=1] |
| 45 | %3 = icmp eq i32 %2, 0 ; <i1> [#uses=1] |
| 46 | br i1 %3, label %bb1, label %bb |
| 47 | |
| 48 | bb: ; preds = %entry |
| 49 | %4 = tail call i32 @bar() nounwind ; <i32> [#uses=0] |
| 50 | ret i32 %1 |
| 51 | |
| 52 | bb1: ; preds = %entry |
| 53 | ret i32 %1 |
| 54 | } |
| 55 | |
| 56 | declare i32 @bar() |