1 ; RUN: opt -S < %s -jump-threading | FileCheck %s
3 ; Keep block addresses alive.
4 @addresses = constant [4 x i8*] [
5 i8* blockaddress(@test1, %L1), i8* blockaddress(@test1, %L2),
6 i8* blockaddress(@test2, %L1), i8* blockaddress(@test2, %L2)
14 ; Check basic jump threading for indirectbr instructions.
17 ; CHECK: br i1 %tobool, label %L1, label %indirectgoto
20 ; CHECK: indirectbr i8* %address, [label %L1, label %L2]
21 define void @test1(i32 %i, i8* %address) nounwind {
24 %tobool = icmp ne i32 %rem, 0
25 br i1 %tobool, label %indirectgoto, label %if.else
27 if.else: ; preds = %entry
28 br label %indirectgoto
30 L1: ; preds = %indirectgoto
34 L2: ; preds = %indirectgoto
38 indirectgoto: ; preds = %if.else, %entry
39 %indirect.goto.dest = phi i8* [ %address, %if.else ], [ blockaddress(@test1, %L1), %entry ]
40 indirectbr i8* %indirect.goto.dest, [label %L1, label %L2]
44 ; Check constant folding of indirectbr
48 ; CHECK-NEXT: call void @bar
49 ; CHECK-NEXT: ret void
50 define void @test2() nounwind {
52 indirectbr i8* blockaddress(@test2, %L1), [label %L1, label %L2]
54 L1: ; preds = %indirectgoto
58 L2: ; preds = %indirectgoto