Skip to content

Commit 025a7ea

Browse files
committed
add remark
1 parent a1f318d commit 025a7ea

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

llvm/lib/Target/X86/X86ConditionalCompares.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ void X86ConditionalCompares::getAnalysisUsage(AnalysisUsage &AU) const {
745745
AU.addPreserved<MachineLoopInfo>();
746746
AU.addRequired<MachineTraceMetrics>();
747747
AU.addPreserved<MachineTraceMetrics>();
748+
AU.addRequired<MachineOptimizationRemarkEmitterPass>();
748749
MachineFunctionPass::getAnalysisUsage(AU);
749750
}
750751

@@ -834,7 +835,8 @@ bool X86ConditionalCompares::runOnMachineFunction(MachineFunction &MF) {
834835
MF.getFunction().getSubprogram(),
835836
&MF.front());
836837
R << "generate " << ore::NV("NumConverted", NumConverted)
837-
<< "CCMP in function to eliminate JCC";
838+
<< " CCMP to eliminate JCC in function "
839+
<< ore::NV("Function", MF.getName());
838840
return R;
839841
});
840842
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; RUN: llc < %s -mattr=+ccmp -pass-remarks=x86-ccmp -pass-remarks-analysis=x86-ccmp -o /dev/null 2>&1 | FileCheck %s
2+
; CHECK-COUNT-3: remark: tmp.c:4:13: convert CMP into conditional CMP
3+
; CHECK: remark: tmp.c:3:0: generate 3 CCMP to eliminate JCC in function foo
4+
5+
define i32 @foo(i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d) !dbg !9 {
6+
entry:
7+
%cmp = icmp slt i32 %a, 1, !dbg !12
8+
%cmp1 = icmp slt i32 %b, 2
9+
%or.cond = and i1 %cmp, %cmp1, !dbg !13
10+
%cmp3 = icmp slt i32 %c, 3
11+
%or.cond5 = and i1 %or.cond, %cmp3, !dbg !14
12+
%tobool = icmp ne i32 %d, 0
13+
%or.cond6 = and i1 %or.cond5, %tobool, !dbg !15
14+
br i1 %or.cond6, label %if.then, label %return, !dbg !13
15+
16+
if.then:
17+
%call = tail call i32 (...) @g()
18+
br label %return
19+
20+
return:
21+
%retval.0 = phi i32 [ %call, %if.then ], [ 6, %entry ]
22+
ret i32 %retval.0
23+
}
24+
25+
declare i32 @g(...)
26+
27+
!llvm.dbg.cu = !{!0}
28+
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
29+
!llvm.ident = !{!8}
30+
31+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
32+
!1 = !DIFile(filename: "tmp.c", directory: "/llvm")
33+
!2 = !{i32 7, !"Dwarf Version", i32 5}
34+
!3 = !{i32 2, !"Debug Info Version", i32 3}
35+
!4 = !{i32 1, !"wchar_size", i32 4}
36+
!5 = !{i32 8, !"PIC Level", i32 2}
37+
!6 = !{i32 7, !"PIE Level", i32 2}
38+
!7 = !{i32 7, !"uwtable", i32 2}
39+
!8 = !{!"clang"}
40+
!9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
41+
!10 = !DISubroutineType(types: !11)
42+
!11 = !{}
43+
!12 = !DILocation(line: 4, column: 9, scope: !9)
44+
!13 = !DILocation(line: 4, column: 13, scope: !9)
45+
!14 = !DILocation(line: 7, column: 12, scope: !9)
46+
!15 = !DILocation(line: 7, column: 5, scope: !9)

0 commit comments

Comments
 (0)