• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -o - -verify-machineinstrs %s | FileCheck %s
2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-unknown-linux-gnu"
4
5@data = external global [3 x i32], align 4
6@store = external global i32, align 4
7
8; %else1 and %then2 end up lowering to identical blocks. These blocks should be
9; merged during tail-merging.
10; CHECK-LABEL: merge_identical_blocks
11; CHECK: movl $data+4
12; CHECK-NOT: movl $data+4
13; CHECK: retq
14define void @merge_identical_blocks(i1 %a, i1 %b) {
15entry:
16  br label %if1
17
18if1:                                              ; predfs = %entry
19  br i1 %a, label %else1, label %if2
20
21else1:                                            ; preds = %if1
22  %ptr.else1 = getelementptr inbounds [3 x i32], [3 x i32]* @data, i64 0, i32 1
23  br label %phi_join
24
25if2:                                              ; preds = %if1
26  br i1 %b, label %then2, label %else2
27
28then2:                                            ; preds = %if2
29  %ptr.then2 = getelementptr inbounds [3 x i32], [3 x i32]* @data, i64 0, i32 1
30  br label %phi_join
31
32else2:                                            ; preds = %if2
33  %ptr.else2 = getelementptr inbounds [3 x i32], [3 x i32]* @data, i64 0, i32 2
34  br label %phi_join
35
36phi_join:                                         ; preds = %else1, %then2, %else2
37  %val.ptr = phi i32* [ %ptr.else1, %else1 ], [ %ptr.then2, %then2 ], [ %ptr.else2, %else2 ]
38  %val = load i32, i32* %val.ptr, align 4
39  store i32 %val, i32* @store, align 4
40  ret void
41}
42