1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
4 define i32 @main(ptr %p, i32 %x, i32 %y) {
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
8 ; CHECK-NEXT: br i1 [[CMP]], label [[BLOCK2:%.*]], label [[BLOCK3:%.*]]
10 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P:%.*]], align 8
11 ; CHECK-NEXT: br label [[BLOCK4:%.*]]
13 ; CHECK-NEXT: [[B:%.*]] = load ptr, ptr [[P]], align 8
14 ; CHECK-NEXT: br label [[BLOCK4]]
16 ; CHECK-NEXT: [[EXISTINGPHI:%.*]] = phi ptr [ [[A]], [[BLOCK2]] ], [ [[B]], [[BLOCK3]] ]
17 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[EXISTINGPHI]], align 4
18 ; CHECK-NEXT: [[E:%.*]] = add i32 [[C]], [[C]]
19 ; CHECK-NEXT: ret i32 [[E]]
22 %cmp = icmp eq i32 %x, %y
23 br i1 %cmp , label %block2, label %block3
34 %existingPHI = phi ptr [ %a, %block2 ], [ %b, %block3 ]
35 %DEAD = load ptr, ptr %p
36 %c = load i32, ptr %DEAD
37 %d = load i32, ptr %existingPHI