1 ; RUN: opt < %s -gvn -S | FileCheck %s
2 ; This testcase tests insertion of no-cost phis. That is,
3 ; when the value is already available in every predecessor,
4 ; and we just need to insert a phi node to merge the available values.
6 @c = global i32 0, align 4
7 @d = global i32 0, align 4
10 define i32 @mai(i32 %foo, i32 %a, i32 %b) {
11 %1 = icmp ne i32 %foo, 0
12 br i1 %1, label %bb1, label %bb2
15 %2 = add nsw i32 %a, %b
16 store i32 %2, i32* @c, align 4
20 %3 = add nsw i32 %a, %b
21 store i32 %3, i32* @d, align 4
25 ; CHECK: pre-phi = phi i32 [ %3, %bb2 ], [ %2, %bb1 ]
26 ; CHECK-NEXT: ret i32 %.pre-phi
27 %4 = add nsw i32 %a, %b