• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
3
4define i32 @main(i32** %p, i32 %x, i32 %y) {
5; CHECK-LABEL: @main(
6; CHECK-NEXT:  block1:
7; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
8; CHECK-NEXT:    br i1 [[CMP]], label [[BLOCK2:%.*]], label [[BLOCK3:%.*]]
9; CHECK:       block2:
10; CHECK-NEXT:    [[A:%.*]] = load i32*, i32** [[P:%.*]]
11; CHECK-NEXT:    br label [[BLOCK4:%.*]]
12; CHECK:       block3:
13; CHECK-NEXT:    [[B:%.*]] = load i32*, i32** [[P]]
14; CHECK-NEXT:    br label [[BLOCK4]]
15; CHECK:       block4:
16; CHECK-NEXT:    [[EXISTINGPHI:%.*]] = phi i32* [ [[A]], [[BLOCK2]] ], [ [[B]], [[BLOCK3]] ]
17; CHECK-NEXT:    [[C:%.*]] = load i32, i32* [[EXISTINGPHI]]
18; CHECK-NEXT:    [[E:%.*]] = add i32 [[C]], [[C]]
19; CHECK-NEXT:    ret i32 [[E]]
20;
21block1:
22  %cmp = icmp eq i32 %x, %y
23  br i1 %cmp , label %block2, label %block3
24
25block2:
26  %a = load i32*, i32** %p
27  br label %block4
28
29block3:
30  %b = load i32*, i32** %p
31  br label %block4
32
33block4:
34  %existingPHI = phi i32* [ %a, %block2 ], [ %b, %block3 ]
35  %DEAD = load i32*, i32** %p
36  %c = load i32, i32* %DEAD
37  %d = load i32, i32* %existingPHI
38  %e = add i32 %c, %d
39  ret i32 %e
40}
41