1 ; RUN: llc < %s -march=x86 > %t 2 ; RUN: not grep neg %t 3 ; RUN: not grep sub.*esp %t 4 ; RUN: not grep esi %t 5 ; RUN: not grep push %t 6 7 ; This corresponds to: 8 ;int t(int a, int b) { 9 ; while (a != b) { 10 ; if (a > b) 11 ; a -= b; 12 ; else 13 ; b -= a; 14 ; } 15 ; return a; 16 ;} 17 18 19 define i32 @t(i32 %a, i32 %b) nounwind { 20 entry: 21 %tmp1434 = icmp eq i32 %a, %b ; <i1> [#uses=1] 22 br i1 %tmp1434, label %bb17, label %bb.outer 23 24 bb.outer: ; preds = %cond_false, %entry 25 %b_addr.021.0.ph = phi i32 [ %b, %entry ], [ %tmp10, %cond_false ] ; <i32> [#uses=5] 26 %a_addr.026.0.ph = phi i32 [ %a, %entry ], [ %a_addr.026.0, %cond_false ] ; <i32> [#uses=1] 27 br label %bb 28 29 bb: ; preds = %cond_true, %bb.outer 30 %indvar = phi i32 [ 0, %bb.outer ], [ %indvar.next, %cond_true ] ; <i32> [#uses=2] 31 %tmp. = sub i32 0, %b_addr.021.0.ph ; <i32> [#uses=1] 32 %tmp.40 = mul i32 %indvar, %tmp. ; <i32> [#uses=1] 33 %a_addr.026.0 = add i32 %tmp.40, %a_addr.026.0.ph ; <i32> [#uses=6] 34 %tmp3 = icmp sgt i32 %a_addr.026.0, %b_addr.021.0.ph ; <i1> [#uses=1] 35 br i1 %tmp3, label %cond_true, label %cond_false 36 37 cond_true: ; preds = %bb 38 %tmp7 = sub i32 %a_addr.026.0, %b_addr.021.0.ph ; <i32> [#uses=2] 39 %tmp1437 = icmp eq i32 %tmp7, %b_addr.021.0.ph ; <i1> [#uses=1] 40 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1] 41 br i1 %tmp1437, label %bb17, label %bb 42 43 cond_false: ; preds = %bb 44 %tmp10 = sub i32 %b_addr.021.0.ph, %a_addr.026.0 ; <i32> [#uses=2] 45 %tmp14 = icmp eq i32 %a_addr.026.0, %tmp10 ; <i1> [#uses=1] 46 br i1 %tmp14, label %bb17, label %bb.outer 47 48 bb17: ; preds = %cond_false, %cond_true, %entry 49 %a_addr.026.1 = phi i32 [ %a, %entry ], [ %tmp7, %cond_true ], [ %a_addr.026.0, %cond_false ] ; <i32> [#uses=1] 50 ret i32 %a_addr.026.1 51 } 52