51 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt < %s -passes=gvn -S | FileCheck %s --check-prefixes=CHECK,MDEP3; RUN: opt < %s -passes='gvn<memoryssa>' -S | FileCheck %s --check-prefixes=CHECK,MSSA4; This testcase tests insertion of no-cost phis. That is,5; when the value is already available in every predecessor,6; and we just need to insert a phi node to merge the available values.7 8@c = global i32 0, align 49@d = global i32 0, align 410 11 12define i32 @mai(i32 %foo, i32 %a, i32 %b) {13; CHECK-LABEL: define i32 @mai(14; CHECK-SAME: i32 [[FOO:%.*]], i32 [[A:%.*]], i32 [[B:%.*]]) {15; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[FOO]], 016; CHECK-NEXT: br i1 [[TMP1]], label %[[BB1:.*]], label %[[BB2:.*]]17; CHECK: [[BB1]]:18; CHECK-NEXT: [[TMP2:%.*]] = add nsw i32 [[A]], [[B]]19; CHECK-NEXT: store i32 [[TMP2]], ptr @c, align 420; CHECK-NEXT: br label %[[MERGEBLOCK:.*]]21; CHECK: [[BB2]]:22; CHECK-NEXT: [[TMP3:%.*]] = add nsw i32 [[A]], [[B]]23; CHECK-NEXT: store i32 [[TMP3]], ptr @d, align 424; CHECK-NEXT: br label %[[MERGEBLOCK]]25; CHECK: [[MERGEBLOCK]]:26; CHECK-NEXT: [[DOTPRE_PHI:%.*]] = phi i32 [ [[TMP3]], %[[BB2]] ], [ [[TMP2]], %[[BB1]] ]27; CHECK-NEXT: ret i32 [[DOTPRE_PHI]]28;29 %1 = icmp ne i32 %foo, 030 br i1 %1, label %bb1, label %bb231 32bb1:33 %2 = add nsw i32 %a, %b34 store i32 %2, ptr @c, align 435 br label %mergeblock36 37bb2:38 %3 = add nsw i32 %a, %b39 store i32 %3, ptr @d, align 440 br label %mergeblock41 42mergeblock:43 %4 = add nsw i32 %a, %b44 ret i32 %445}46 47 48;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:49; MDEP: {{.*}}50; MSSA: {{.*}}51