1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=spec-phis < %s | FileCheck %s
3 ; Make sure convergent and noduplicate calls aren't duplicated.
5 declare i32 @llvm.convergent(i32) #0
6 declare i32 @llvm.noduplicate(i32) #1
7 declare i32 @llvm.regular(i32) #2
9 define i32 @test_convergent(i1 %flag, i32 %arg) #0 {
10 ; CHECK-LABEL: @test_convergent(
12 ; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
14 ; CHECK-NEXT: br label [[EXIT:%.*]]
16 ; CHECK-NEXT: br label [[EXIT]]
18 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[A]] ], [ 11, [[B]] ]
19 ; CHECK-NEXT: [[SUM:%.*]] = call i32 @llvm.convergent(i32 [[P]])
20 ; CHECK-NEXT: ret i32 [[SUM]]
23 br i1 %flag, label %a, label %b
32 %p = phi i32 [ 7, %a ], [ 11, %b ]
33 %sum = call i32 @llvm.convergent(i32 %p)
37 define i32 @test_noduplicate(i1 %flag, i32 %arg) #1 {
38 ; CHECK-LABEL: @test_noduplicate(
40 ; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
42 ; CHECK-NEXT: br label [[EXIT:%.*]]
44 ; CHECK-NEXT: br label [[EXIT]]
46 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 7, [[A]] ], [ 11, [[B]] ]
47 ; CHECK-NEXT: [[SUM:%.*]] = call i32 @llvm.noduplicate(i32 [[P]])
48 ; CHECK-NEXT: ret i32 [[SUM]]
51 br i1 %flag, label %a, label %b
60 %p = phi i32 [ 7, %a ], [ 11, %b ]
61 %sum = call i32 @llvm.noduplicate(i32 %p)
65 ; Otherwise identical function which should be transformed.
66 define i32 @test_reference(i1 %flag, i32 %arg) #2 {
67 ; CHECK-LABEL: @test_reference(
69 ; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[A:%.*]], label [[B:%.*]]
71 ; CHECK-NEXT: [[SUM_0:%.*]] = call i32 @llvm.regular(i32 7)
72 ; CHECK-NEXT: br label [[EXIT:%.*]]
74 ; CHECK-NEXT: [[SUM_1:%.*]] = call i32 @llvm.regular(i32 11)
75 ; CHECK-NEXT: br label [[EXIT]]
77 ; CHECK-NEXT: [[SUM_PHI:%.*]] = phi i32 [ [[SUM_0]], [[A]] ], [ [[SUM_1]], [[B]] ]
78 ; CHECK-NEXT: ret i32 [[SUM_PHI]]
81 br i1 %flag, label %a, label %b
90 %p = phi i32 [ 7, %a ], [ 11, %b ]
91 %sum = call i32 @llvm.regular(i32 %p)
96 attributes #0 = { nounwind readnone convergent speculatable }
97 attributes #1 = { nounwind readnone noduplicate speculatable }
98 attributes #2 = { nounwind readnone speculatable }