; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt < %s -passes=gvn -S | FileCheck %s --check-prefixes=CHECK,MDEP ; RUN: opt < %s -passes='gvn' -S | FileCheck %s --check-prefixes=CHECK,MSSA ; This testcase tests insertion of no-cost phis. That is, ; when the value is already available in every predecessor, ; and we just need to insert a phi node to merge the available values. @c = global i32 0, align 4 @d = global i32 0, align 4 define i32 @mai(i32 %foo, i32 %a, i32 %b) { ; CHECK-LABEL: define i32 @mai( ; CHECK-SAME: i32 [[FOO:%.*]], i32 [[A:%.*]], i32 [[B:%.*]]) { ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[FOO]], 0 ; CHECK-NEXT: br i1 [[TMP1]], label %[[BB1:.*]], label %[[BB2:.*]] ; CHECK: [[BB1]]: ; CHECK-NEXT: [[TMP2:%.*]] = add nsw i32 [[A]], [[B]] ; CHECK-NEXT: store i32 [[TMP2]], ptr @c, align 4 ; CHECK-NEXT: br label %[[MERGEBLOCK:.*]] ; CHECK: [[BB2]]: ; CHECK-NEXT: [[TMP3:%.*]] = add nsw i32 [[A]], [[B]] ; CHECK-NEXT: store i32 [[TMP3]], ptr @d, align 4 ; CHECK-NEXT: br label %[[MERGEBLOCK]] ; CHECK: [[MERGEBLOCK]]: ; CHECK-NEXT: [[DOTPRE_PHI:%.*]] = phi i32 [ [[TMP3]], %[[BB2]] ], [ [[TMP2]], %[[BB1]] ] ; CHECK-NEXT: ret i32 [[DOTPRE_PHI]] ; %1 = icmp ne i32 %foo, 0 br i1 %1, label %bb1, label %bb2 bb1: %2 = add nsw i32 %a, %b store i32 %2, ptr @c, align 4 br label %mergeblock bb2: %3 = add nsw i32 %a, %b store i32 %3, ptr @d, align 4 br label %mergeblock mergeblock: %4 = add nsw i32 %a, %b ret i32 %4 } ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: ; MDEP: {{.*}} ; MSSA: {{.*}}