1 ; RUN: llc < %s | FileCheck %s 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 ; CHECK: test: 11 ; CHECK-NOT: ret 12 ; CHECK: testl (%{{.*}}), %{{.*}} 13 ; CHECK: ret 14 15 entry: 16 %0 = load i32* %P, align 4 ; <i32> [#uses=3] 17 %1 = load i32* %G, align 4 ; <i32> [#uses=1] 18 %2 = and i32 %1, %0 ; <i32> [#uses=1] 19 %3 = icmp eq i32 %2, 0 ; <i1> [#uses=1] 20 br i1 %3, label %bb1, label %bb 21 22 bb: ; preds = %entry 23 %4 = tail call i32 @bar() nounwind ; <i32> [#uses=0] 24 ret i32 %0 25 26 bb1: ; preds = %entry 27 ret i32 %0 28 } 29 30 define i32 @test2(i32* %P, i32* %G) nounwind { 31 ; CHECK: test2: 32 ; CHECK-NOT: ret 33 ; CHECK: testl (%{{.*}}), %{{.*}} 34 ; CHECK: ret 35 36 entry: 37 %0 = load i32* %P, align 4 ; <i32> [#uses=3] 38 %1 = load i32* %G, align 4 ; <i32> [#uses=1] 39 %2 = and i32 %0, %1 ; <i32> [#uses=1] 40 %3 = icmp eq i32 %2, 0 ; <i1> [#uses=1] 41 br i1 %3, label %bb1, label %bb 42 43 bb: ; preds = %entry 44 %4 = tail call i32 @bar() nounwind ; <i32> [#uses=0] 45 ret i32 %0 46 47 bb1: ; preds = %entry 48 ret i32 %0 49 } 50 51 define i32 @test3(i32* %P, i32* %G) nounwind { 52 ; CHECK: test3: 53 ; CHECK-NOT: ret 54 ; CHECK: testl (%{{.*}}), %{{.*}} 55 ; CHECK: ret 56 57 entry: 58 %0 = load i32* %P, align 4 ; <i32> [#uses=3] 59 %1 = load i32* %G, align 4 ; <i32> [#uses=1] 60 %2 = and i32 %0, %1 ; <i32> [#uses=1] 61 %3 = icmp eq i32 %2, 0 ; <i1> [#uses=1] 62 br i1 %3, label %bb1, label %bb 63 64 bb: ; preds = %entry 65 %4 = tail call i32 @bar() nounwind ; <i32> [#uses=0] 66 ret i32 %1 67 68 bb1: ; preds = %entry 69 ret i32 %1 70 } 71 72 declare i32 @bar() 73