blob: 75bc19f091f16c6e1b0ffb043934bd9b19ea03c4 [file] [log] [blame]
Mircea Trofinff3bed02019-05-10 21:27:55 +00001; RUN: llc -x86-discriminate-memops < %s | FileCheck %s
2; RUN: llc -x86-discriminate-memops -x86-bypass-prefetch-instructions=0 < %s | FileCheck %s -check-prefix=NOBYPASS
3;
4; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling:
5; int sum(int* arr, int pos1, int pos2) {
6; return arr[pos1] + arr[pos2];
7; }
8;
9; ModuleID = 'test.cc'
10source_filename = "test.cc"
11target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
12target triple = "x86_64-unknown-linux-gnu"
13
14declare void @llvm.prefetch(i8 *, i32, i32, i32)
15; Function Attrs: norecurse nounwind readonly uwtable
16define i32 @sum(i32* %arr, i32 %pos1, i32 %pos2) !dbg !7 {
17entry:
18 %idxprom = sext i32 %pos1 to i64, !dbg !9
19 %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %idxprom, !dbg !9
20 %0 = load i32, i32* %arrayidx, align 4, !dbg !9, !tbaa !10
21 %idxprom1 = sext i32 %pos2 to i64, !dbg !14
22 %arrayidx2 = getelementptr inbounds i32, i32* %arr, i64 %idxprom1, !dbg !14
23 %addr = bitcast i32* %arrayidx2 to i8*
24 call void @llvm.prefetch(i8* %addr, i32 0, i32 3, i32 1)
25 %1 = load i32, i32* %arrayidx2, align 4, !dbg !14, !tbaa !10
26 %add = add nsw i32 %1, %0, !dbg !15
27 ret i32 %add, !dbg !16
28}
29
30attributes #0 = { "target-cpu"="x86-64" }
31
32!llvm.dbg.cu = !{!0}
33!llvm.module.flags = !{!3, !4, !5}
34!llvm.ident = !{!6}
35
36!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true)
37!1 = !DIFile(filename: "test.cc", directory: "/tmp")
38!2 = !{}
39!3 = !{i32 2, !"Dwarf Version", i32 4}
40!4 = !{i32 2, !"Debug Info Version", i32 3}
41!5 = !{i32 1, !"wchar_size", i32 4}
42!6 = !{!"clang version 7.0.0 (trunk 322155) (llvm/trunk 322159)"}
43!7 = distinct !DISubprogram(name: "sum", linkageName: "sum", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
44!8 = !DISubroutineType(types: !2)
45!9 = !DILocation(line: 2, column: 10, scope: !7)
46!10 = !{!11, !11, i64 0}
47!11 = !{!"int", !12, i64 0}
48!12 = !{!"omnipotent char", !13, i64 0}
49!13 = !{!"Simple C++ TBAA"}
50!14 = !DILocation(line: 2, column: 22, scope: !7)
51!15 = !DILocation(line: 2, column: 20, scope: !7)
52!16 = !DILocation(line: 2, column: 3, scope: !7)
53
54;CHECK-LABEL: sum:
55;CHECK: # %bb.0:
56;CHECK: prefetcht0 (%rdi,%rax,4)
57;CHECK-NEXT: movl (%rdi,%rax,4), %eax
58;CHECK-NEXT: .loc 1 2 20 discriminator 2 # test.cc:2:20
59;CHECK-NEXT: addl (%rdi,%rcx,4), %eax
60;CHECK-NEXT: .loc 1 2 3 # test.cc:2:3
61
62;NOBYPASS-LABEL: sum:
63;NOBYPASS: # %bb.0:
64;NOBYPASS: prefetcht0 (%rdi,%rax,4)
65;NOBYPASS-NEXT: .loc 1 2 22
66;NOBYPASS-NEXT: movl (%rdi,%rax,4), %eax
67;NOBYPASS-NEXT: .loc 1 2 20 {{.*}} discriminator 2 # test.cc:2:20
68;NOBYPASS-NEXT: addl (%rdi,%rcx,4), %eax
69;NOBYPASS-NEXT: .loc 1 2 3 # test.cc:2:3