74 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 42; RUN: opt -passes=newgvn -S < %s | FileCheck %s3 4; Check that the redundant load from %if.then is removed.5; Also, check that the debug location associated to load %0 still refers to6; line 3 and not line 6.7 8target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"9 10 11define i32 @test_redundant_load(i32 %X, ptr %Y) !dbg !6 {12; CHECK-LABEL: define i32 @test_redundant_load(13; CHECK-SAME: i32 [[X:%.*]], ptr [[Y:%.*]]) !dbg [[DBG6:![0-9]+]] {14; CHECK-NEXT: entry:15; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !dbg [[DBG8:![0-9]+]]16; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], -1, !dbg [[DBG9:![0-9]+]]17; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]], !dbg [[DBG9]]18; CHECK: if.then:19; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP0]], !dbg [[DBG10:![0-9]+]]20; CHECK-NEXT: call void @foo(), !dbg [[DBG11:![0-9]+]]21; CHECK-NEXT: br label [[IF_END]], !dbg [[DBG12:![0-9]+]]22; CHECK: if.end:23; CHECK-NEXT: [[RESULT_0:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ [[TMP0]], [[ENTRY:%.*]] ]24; CHECK-NEXT: ret i32 [[RESULT_0]], !dbg [[DBG13:![0-9]+]]25;26entry:27 %0 = load i32, ptr %Y, align 4, !dbg !828 %cmp = icmp sgt i32 %X, -1, !dbg !929 br i1 %cmp, label %if.then, label %if.end, !dbg !930 31if.then: ; preds = %entry32 %1 = load i32, ptr %Y, align 4, !dbg !1033 %add = add nsw i32 %0, %1, !dbg !1034 call void @foo(), !dbg !1135 br label %if.end, !dbg !1236 37if.end: ; preds = %if.then, %entry38 %Result.0 = phi i32 [ %add, %if.then ], [ %0, %entry ]39 ret i32 %Result.0, !dbg !1340}41 42declare void @foo()43 44!llvm.dbg.cu = !{!0}45!llvm.module.flags = !{!3, !4, !5}46 47!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)48!1 = !DIFile(filename: "test.cpp", directory: "")49!2 = !{}50!3 = !{i32 2, !"Dwarf Version", i32 4}51!4 = !{i32 2, !"Debug Info Version", i32 3}52!5 = !{i32 1, !"PIC Level", i32 2}53!6 = distinct !DISubprogram(name: "test_redundant_load", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)54!7 = !DISubroutineType(types: !2)55!8 = !DILocation(line: 3, scope: !6)56!9 = !DILocation(line: 5, scope: !6)57!10 = !DILocation(line: 6, scope: !6)58!11 = !DILocation(line: 7, scope: !6)59!12 = !DILocation(line: 8, scope: !6)60!13 = !DILocation(line: 10, scope: !6)61;.62; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: [[META1:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: [[META2:![0-9]+]])63; CHECK: [[META1]] = !DIFile(filename: "test.cpp", directory: "")64; CHECK: [[META2]] = !{}65; CHECK: [[DBG6]] = distinct !DISubprogram(name: "test_redundant_load", scope: [[META1]], file: [[META1]], line: 2, type: [[META7:![0-9]+]], scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META2]])66; CHECK: [[META7]] = !DISubroutineType(types: [[META2]])67; CHECK: [[DBG8]] = !DILocation(line: 3, scope: [[DBG6]])68; CHECK: [[DBG9]] = !DILocation(line: 5, scope: [[DBG6]])69; CHECK: [[DBG10]] = !DILocation(line: 6, scope: [[DBG6]])70; CHECK: [[DBG11]] = !DILocation(line: 7, scope: [[DBG6]])71; CHECK: [[DBG12]] = !DILocation(line: 8, scope: [[DBG6]])72; CHECK: [[DBG13]] = !DILocation(line: 10, scope: [[DBG6]])73;.74