Skip to content

Commit f233b92

Browse files
committed
[PGO][PGSO] Add profile guided size optimization to LegalizeDAG.
Reviewers: davidxl Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D83333
1 parent 8ef4724 commit f233b92

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3319,7 +3319,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
33193319
// Check to see if this FP immediate is already legal.
33203320
// If this is a legal constant, turn it into a TargetConstantFP node.
33213321
if (!TLI.isFPImmLegal(CFP->getValueAPF(), Node->getValueType(0),
3322-
DAG.getMachineFunction().getFunction().hasOptSize()))
3322+
DAG.shouldOptForSize()))
33233323
Results.push_back(ExpandConstantFP(CFP, true));
33243324
break;
33253325
}

llvm/test/CodeGen/AArch64/arm64-fp-imm-size.ll

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,38 @@ define fp128 @baz() optsize {
3838
; CHECK-NEXT: ret
3939
ret fp128 0xL00000000000000000000000000000000
4040
}
41+
42+
; CHECK: literal8
43+
; CHECK: .quad 0x0000001fffffffd
44+
define double @foo2_pgso() !prof !14 {
45+
; CHECK: _foo2_pgso:
46+
; CHECK: adrp x[[REG:[0-9]+]], lCPI4_0@PAGE
47+
; CHECK: ldr d0, [x[[REG]], lCPI4_0@PAGEOFF]
48+
; CHECK-NEXT: ret
49+
ret double 0x1FFFFFFFd1
50+
}
51+
52+
define float @bar_pgso() !prof !14 {
53+
; CHECK: _bar_pgso:
54+
; CHECK: adrp x[[REG:[0-9]+]], lCPI5_0@PAGE
55+
; CHECK: ldr s0, [x[[REG]], lCPI5_0@PAGEOFF]
56+
; CHECK-NEXT: ret
57+
ret float 0x400921FB80000000
58+
}
59+
60+
!llvm.module.flags = !{!0}
61+
!0 = !{i32 1, !"ProfileSummary", !1}
62+
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
63+
!2 = !{!"ProfileFormat", !"InstrProf"}
64+
!3 = !{!"TotalCount", i64 10000}
65+
!4 = !{!"MaxCount", i64 10}
66+
!5 = !{!"MaxInternalCount", i64 1}
67+
!6 = !{!"MaxFunctionCount", i64 1000}
68+
!7 = !{!"NumCounts", i64 3}
69+
!8 = !{!"NumFunctions", i64 3}
70+
!9 = !{!"DetailedSummary", !10}
71+
!10 = !{!11, !12, !13}
72+
!11 = !{i32 10000, i64 100, i32 1}
73+
!12 = !{i32 999000, i64 100, i32 1}
74+
!13 = !{i32 999999, i64 1, i32 2}
75+
!14 = !{!"function_entry_count", i64 0}

0 commit comments

Comments
 (0)