1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=gvn -o - %s | FileCheck %s
4 define i32 @foo(i1 %cond, ptr %q, ptr %p) {
7 ; CHECK-NEXT: [[V0:%.*]] = call i32 @llvm.convergent(i32 0)
8 ; CHECK-NEXT: store i32 [[V0]], ptr [[Q:%.*]], align 4
9 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[PRE:%.*]], label [[MERGE:%.*]]
11 ; CHECK-NEXT: [[T0:%.*]] = load i32, ptr [[P:%.*]], align 4
12 ; CHECK-NEXT: br label [[MERGE]]
14 ; CHECK-NEXT: [[M0:%.*]] = phi i32 [ [[T0]], [[PRE]] ], [ 0, [[ENTRY:%.*]] ]
15 ; CHECK-NEXT: [[R0:%.*]] = call i32 @llvm.convergent(i32 [[M0]])
16 ; CHECK-NEXT: ret i32 [[R0]]
19 %v0 = call i32 @llvm.convergent(i32 0)
21 br i1 %cond, label %pre, label %merge
24 %t0 = load i32, ptr %p
28 %m0 = phi i32 [ %t0, %pre ], [ 0, %entry ]
29 %r0 = call i32 @llvm.convergent(i32 %m0)
33 declare i32 @llvm.convergent(i32) convergent nounwind readnone willreturn