; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt -passes=gvn -S < %s | FileCheck %s --check-prefixes=CHECK,MDEP ; RUN: opt -passes='gvn' -S < %s | FileCheck %s --check-prefixes=CHECK,MSSA target datalayout = "e-p:64:64:64" @G = external global [100 x i32] define i32 @foo(i32 %x, i32 %z) !dbg !6 { ; CHECK-LABEL: define i32 @foo( ; CHECK-SAME: i32 [[X:%.*]], i32 [[Z:%.*]]) !dbg [[DBG5:![0-9]+]] { ; CHECK-NEXT: [[ENTRY:.*:]] ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[Z]], 0, !dbg [[DBG8:![0-9]+]] ; CHECK-NEXT: br i1 [[TOBOOL]], label %[[ENTRY_END_CRIT_EDGE:.*]], label %[[THEN:.*]], !dbg [[DBG8]] ; CHECK: [[ENTRY_END_CRIT_EDGE]]: ; CHECK-NEXT: [[J_PHI_TRANS_INSERT:%.*]] = sext i32 [[X]] to i64 ; CHECK-NEXT: [[Q_PHI_TRANS_INSERT:%.*]] = getelementptr [100 x i32], ptr @G, i64 0, i64 [[J_PHI_TRANS_INSERT]] ; CHECK-NEXT: [[N_PRE:%.*]] = load i32, ptr [[Q_PHI_TRANS_INSERT]], align 4, !dbg [[DBG9:![0-9]+]] ; CHECK-NEXT: br label %[[END:.*]], !dbg [[DBG8]] ; CHECK: [[THEN]]: ; CHECK-NEXT: [[I:%.*]] = sext i32 [[X]] to i64, !dbg [[DBG10:![0-9]+]] ; CHECK-NEXT: [[P:%.*]] = getelementptr [100 x i32], ptr @G, i64 0, i64 [[I]], !dbg [[DBG10]] ; CHECK-NEXT: store i32 [[Z]], ptr [[P]], align 4, !dbg [[DBG10]] ; CHECK-NEXT: br label %[[END]], !dbg [[DBG10]] ; CHECK: [[END]]: ; CHECK-NEXT: [[J_PRE_PHI:%.*]] = phi i64 [ [[J_PHI_TRANS_INSERT]], %[[ENTRY_END_CRIT_EDGE]] ], [ [[I]], %[[THEN]] ], !dbg [[DBG11:![0-9]+]] ; CHECK-NEXT: [[N:%.*]] = phi i32 [ [[N_PRE]], %[[ENTRY_END_CRIT_EDGE]] ], [ [[Z]], %[[THEN]] ], !dbg [[DBG9]] ; CHECK-NEXT: [[Q:%.*]] = getelementptr [100 x i32], ptr @G, i64 0, i64 [[J_PRE_PHI]], !dbg [[DBG12:![0-9]+]] ; CHECK-NEXT: ret i32 [[N]], !dbg [[DBG9]] ; entry: %tobool = icmp eq i32 %z, 0, !dbg !7 br i1 %tobool, label %end, label %then, !dbg !7 then: %i = sext i32 %x to i64, !dbg !8 %p = getelementptr [100 x i32], ptr @G, i64 0, i64 %i, !dbg !8 store i32 %z, ptr %p, !dbg !8 br label %end, !dbg !8 end: %j = sext i32 %x to i64, !dbg !9 %q = getelementptr [100 x i32], ptr @G, i64 0, i64 %j, !dbg !10 %n = load i32, ptr %q, !dbg !11 ret i32 %n, !dbg !11 } !llvm.module.flags = !{!0, !1, !2} !llvm.dbg.cu = !{!12} !0 = !{i32 2, !"Dwarf Version", i32 4} !1 = !{i32 2, !"Debug Info Version", i32 3} !2 = !{i32 1, !"PIC Level", i32 2} !3 = !{} !4 = !DISubroutineType(types: !3) !5 = !DIFile(filename: "a.cc", directory: "/tmp") !6 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 42, type: !4, isLocal: false, isDefinition: true, scopeLine: 43, flags: DIFlagPrototyped, isOptimized: false, unit: !12, retainedNodes: !3) !7 = !DILocation(line: 43, column: 1, scope: !6) !8 = !DILocation(line: 44, column: 1, scope: !6) !9 = !DILocation(line: 45, column: 1, scope: !6) !10 = !DILocation(line: 46, column: 1, scope: !6) !11 = !DILocation(line: 47, column: 1, scope: !6) !12 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang", file: !5, isOptimized: true, flags: "-O2", splitDebugFilename: "abc.debug", emissionKind: 2) ;. ; CHECK: [[META3:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: [[META4:![0-9]+]], producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 0, splitDebugFilename: "abc.debug", emissionKind: LineTablesOnly) ; CHECK: [[META4]] = !DIFile(filename: "{{.*}}a.cc", directory: {{.*}}) ; CHECK: [[DBG5]] = distinct !DISubprogram(name: "foo", scope: [[META4]], file: [[META4]], line: 42, type: [[META6:![0-9]+]], scopeLine: 43, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: [[META3]], retainedNodes: [[META7:![0-9]+]]) ; CHECK: [[META6]] = !DISubroutineType(types: [[META7]]) ; CHECK: [[META7]] = !{} ; CHECK: [[DBG8]] = !DILocation(line: 43, column: 1, scope: [[DBG5]]) ; CHECK: [[DBG9]] = !DILocation(line: 47, column: 1, scope: [[DBG5]]) ; CHECK: [[DBG10]] = !DILocation(line: 44, column: 1, scope: [[DBG5]]) ; CHECK: [[DBG11]] = !DILocation(line: 45, column: 1, scope: [[DBG5]]) ; CHECK: [[DBG12]] = !DILocation(line: 46, column: 1, scope: [[DBG5]]) ;. ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: ; MDEP: {{.*}} ; MSSA: {{.*}}