llvm.org GIT mirror llvm / cffb528
Fix code emission for conditional branches. Patch by Collin Winter! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70898 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 11 years ago
2 changed file(s) with 30 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
10911091 const BranchInst* br = cast(I);
10921092 Out << "BranchInst::Create(" ;
10931093 if (br->getNumOperands() == 3 ) {
1094 Out << opNames[0] << ", "
1094 Out << opNames[2] << ", "
10951095 << opNames[1] << ", "
1096 << opNames[2] << ", ";
1096 << opNames[0] << ", ";
10971097
10981098 } else if (br->getNumOperands() == 1) {
10991099 Out << opNames[0] << ", ";
0 ; RUN: llvm-as < %s | llc -march=cpp -cppgen=program -f -o %t
1 ; RUN: grep "BranchInst::Create(label_if_then, label_if_end, int1_cmp, label_entry);" %t
2
3 define i32 @some_func(i32 %a) nounwind {
4 entry:
5 %retval = alloca i32 ; [#uses=2]
6 %a.addr = alloca i32 ; [#uses=8]
7 store i32 %a, i32* %a.addr
8 %tmp = load i32* %a.addr ; [#uses=1]
9 %inc = add i32 %tmp, 1 ; [#uses=1]
10 store i32 %inc, i32* %a.addr
11 %tmp1 = load i32* %a.addr ; [#uses=1]
12 %cmp = icmp slt i32 %tmp1, 3 ; [#uses=1]
13 br i1 %cmp, label %if.then, label %if.end
14
15 if.then: ; preds = %entry
16 store i32 7, i32* %a.addr
17 br label %if.end
18
19 if.end: ; preds = %if.then, %entry
20 %tmp2 = load i32* %a.addr ; [#uses=1]
21 %inc3 = add i32 %tmp2, 1 ; [#uses=1]
22 store i32 %inc3, i32* %a.addr
23 %tmp4 = load i32* %a.addr ; [#uses=1]
24 store i32 %tmp4, i32* %retval
25 %0 = load i32* %retval ; [#uses=1]
26 ret i32 %0
27 }