1 ; RUN: opt -S -passes=mergefunc < %s | FileCheck %s
3 ; These two functions are identical. The basic block labels are the same, and
4 ; induce the same CFG. We are testing that block addresses within different
5 ; functions are compared by their value, and not based on order. Both functions
6 ; come from the same C-code, but in the first the two val_0/val_1 basic blocks
7 ; are in a different order (they were manually switched post-compilation).
9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-unknown-linux-gnu"
12 define i32 @_Z1fi(i32 %i) #0 {
14 %i.addr = alloca i32, align 4
15 %ret = alloca i32, align 4
16 %l = alloca ptr, align 8
17 store i32 %i, ptr %i.addr, align 4
18 store i32 0, ptr %ret, align 4
19 store ptr blockaddress(@_Z1fi, %val_0), ptr %l, align 8
20 %0 = load i32, ptr %i.addr, align 4
21 %and = and i32 %0, 256
22 %cmp = icmp eq i32 %and, 0
23 br i1 %cmp, label %if.then, label %if.end
26 store ptr blockaddress(@_Z1fi, %val_1), ptr %l, align 8
30 %1 = load ptr, ptr %l, align 8
31 br label %indirectgoto
34 store i32 42, ptr %ret, align 4
38 store i32 12, ptr %ret, align 4
43 %2 = load i32, ptr %ret, align 4
47 %indirect.goto.dest = phi ptr [ %1, %if.end ]
48 indirectbr ptr %indirect.goto.dest, [label %val_0, label %val_1]
51 define i32 @_Z1gi(i32 %i) #0 {
52 ; CHECK-LABEL: define i32 @_Z1gi
53 ; CHECK-NEXT: tail call i32 @_Z1fi
56 %i.addr = alloca i32, align 4
57 %ret = alloca i32, align 4
58 %l = alloca ptr, align 8
59 store i32 %i, ptr %i.addr, align 4
60 store i32 0, ptr %ret, align 4
61 store ptr blockaddress(@_Z1gi, %val_0), ptr %l, align 8
62 %0 = load i32, ptr %i.addr, align 4
63 %and = and i32 %0, 256
64 %cmp = icmp eq i32 %and, 0
65 br i1 %cmp, label %if.then, label %if.end
68 store ptr blockaddress(@_Z1gi, %val_1), ptr %l, align 8
72 %1 = load ptr, ptr %l, align 8
73 br label %indirectgoto
76 store i32 12, ptr %ret, align 4
80 store i32 42, ptr %ret, align 4
84 %2 = load i32, ptr %ret, align 4
88 %indirect.goto.dest = phi ptr [ %1, %if.end ]
89 indirectbr ptr %indirect.goto.dest, [label %val_0, label %val_1]