blob: 407bdf7524b11a3606611839af43511af3a535af [file] [log] [blame]
Chad Rosier1a1531d2012-01-26 18:24:25 +00001; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s
2
3; We should be able to tail-duplicate the basic block containing the indirectbr
4; into all of its predecessors.
Stephen Lind24ab202013-07-14 06:24:09 +00005; CHECK-LABEL: fn:
Chad Rosier1a1531d2012-01-26 18:24:25 +00006; CHECK: mov pc
7; CHECK: mov pc
8; CHECK: mov pc
9
10@fn.codetable = internal unnamed_addr constant [3 x i8*] [i8* blockaddress(@fn, %RETURN), i8* blockaddress(@fn, %INCREMENT), i8* blockaddress(@fn, %DECREMENT)], align 4
11
12define i32 @fn(i32* nocapture %opcodes) nounwind readonly ssp {
13entry:
David Blaikiea79ac142015-02-27 21:17:42 +000014 %0 = load i32, i32* %opcodes, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000015 %arrayidx = getelementptr inbounds [3 x i8*], [3 x i8*]* @fn.codetable, i32 0, i32 %0
Chad Rosier1a1531d2012-01-26 18:24:25 +000016 br label %indirectgoto
17
18INCREMENT: ; preds = %indirectgoto
19 %inc = add nsw i32 %result.0, 1
David Blaikiea79ac142015-02-27 21:17:42 +000020 %1 = load i32, i32* %opcodes.addr.0, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000021 %arrayidx2 = getelementptr inbounds [3 x i8*], [3 x i8*]* @fn.codetable, i32 0, i32 %1
Chad Rosier1a1531d2012-01-26 18:24:25 +000022 br label %indirectgoto
23
24DECREMENT: ; preds = %indirectgoto
25 %dec = add nsw i32 %result.0, -1
David Blaikiea79ac142015-02-27 21:17:42 +000026 %2 = load i32, i32* %opcodes.addr.0, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000027 %arrayidx4 = getelementptr inbounds [3 x i8*], [3 x i8*]* @fn.codetable, i32 0, i32 %2
Chad Rosier1a1531d2012-01-26 18:24:25 +000028 br label %indirectgoto
29
30indirectgoto: ; preds = %DECREMENT, %INCREMENT, %entry
31 %result.0 = phi i32 [ 0, %entry ], [ %dec, %DECREMENT ], [ %inc, %INCREMENT ]
32 %opcodes.pn = phi i32* [ %opcodes, %entry ], [ %opcodes.addr.0, %DECREMENT ], [ %opcodes.addr.0, %INCREMENT ]
33 %indirect.goto.dest.in = phi i8** [ %arrayidx, %entry ], [ %arrayidx4, %DECREMENT ], [ %arrayidx2, %INCREMENT ]
David Blaikie79e6c742015-02-27 19:29:02 +000034 %opcodes.addr.0 = getelementptr inbounds i32, i32* %opcodes.pn, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000035 %indirect.goto.dest = load i8*, i8** %indirect.goto.dest.in, align 4
Chad Rosier1a1531d2012-01-26 18:24:25 +000036 indirectbr i8* %indirect.goto.dest, [label %RETURN, label %INCREMENT, label %DECREMENT]
37
38RETURN: ; preds = %indirectgoto
39 ret i32 %result.0
40}