Skip to content

Commit 1285781

Browse files
committed
[CostModel] add tests for math library calls; NFC
This is a partial un-revert of 32dd587 (originally df09f82 ). I'm adding back the baseline tests first, so we don't have to back-track as much in case there are still problems.
1 parent 99cf39b commit 1285781

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

llvm/test/Analysis/CostModel/ARM/intrinsic-cost-kinds.ll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ declare <16 x i32> @llvm.smax.v16i32(<16 x i32>, <16 x i32>)
1616
declare float @llvm.fmuladd.f32(float, float, float)
1717
declare <16 x float> @llvm.fmuladd.v16f32(<16 x float>, <16 x float>, <16 x float>)
1818

19+
declare float @llvm.log2.f32(float)
20+
declare <16 x float> @llvm.log2.v16f32(<16 x float>)
21+
1922
declare i32 @llvm.cttz.i32(i32, i1)
2023
declare <16 x i32> @llvm.cttz.v16i32(<16 x i32>, i1)
2124

@@ -83,6 +86,32 @@ define void @fmuladd(float %a, float %b, float %c, <16 x float> %va, <16 x float
8386
ret void
8487
}
8588

89+
define void @log2(float %a, <16 x float> %va) {
90+
; THRU-LABEL: 'log2'
91+
; THRU-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %s = call float @llvm.log2.f32(float %a)
92+
; THRU-NEXT: Cost Model: Found an estimated cost of 672 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
93+
; THRU-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
94+
;
95+
; LATE-LABEL: 'log2'
96+
; LATE-NEXT: Cost Model: Found an estimated cost of 40 for instruction: %s = call float @llvm.log2.f32(float %a)
97+
; LATE-NEXT: Cost Model: Found an estimated cost of 40 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
98+
; LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
99+
;
100+
; SIZE-LABEL: 'log2'
101+
; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s = call float @llvm.log2.f32(float %a)
102+
; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
103+
; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
104+
;
105+
; SIZE_LATE-LABEL: 'log2'
106+
; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s = call float @llvm.log2.f32(float %a)
107+
; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
108+
; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
109+
;
110+
%s = call float @llvm.log2.f32(float %a)
111+
%v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
112+
ret void
113+
}
114+
86115
define void @cttz(i32 %a, <16 x i32> %va) {
87116
; THRU-LABEL: 'cttz'
88117
; THRU-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s = call i32 @llvm.cttz.i32(i32 %a, i1 false)

llvm/test/Analysis/CostModel/X86/intrinsic-cost-kinds.ll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ declare <16 x i32> @llvm.smax.v16i32(<16 x i32>, <16 x i32>)
1919
declare float @llvm.fmuladd.f32(float, float, float)
2020
declare <16 x float> @llvm.fmuladd.v16f32(<16 x float>, <16 x float>, <16 x float>)
2121

22+
declare float @llvm.log2.f32(float)
23+
declare <16 x float> @llvm.log2.v16f32(<16 x float>)
24+
2225
declare i32 @llvm.cttz.i32(i32, i1)
2326
declare <16 x i32> @llvm.cttz.v16i32(<16 x i32>, i1)
2427

@@ -114,6 +117,32 @@ define void @fmuladd(float %a, float %b, float %c, <16 x float> %va, <16 x float
114117
ret void
115118
}
116119

120+
define void @log2(float %a, <16 x float> %va) {
121+
; THRU-LABEL: 'log2'
122+
; THRU-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %s = call float @llvm.log2.f32(float %a)
123+
; THRU-NEXT: Cost Model: Found an estimated cost of 184 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
124+
; THRU-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
125+
;
126+
; LATE-LABEL: 'log2'
127+
; LATE-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %s = call float @llvm.log2.f32(float %a)
128+
; LATE-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
129+
; LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
130+
;
131+
; SIZE-LABEL: 'log2'
132+
; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s = call float @llvm.log2.f32(float %a)
133+
; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
134+
; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
135+
;
136+
; SIZE_LATE-LABEL: 'log2'
137+
; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s = call float @llvm.log2.f32(float %a)
138+
; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
139+
; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
140+
;
141+
%s = call float @llvm.log2.f32(float %a)
142+
%v = call <16 x float> @llvm.log2.v16f32(<16 x float> %va)
143+
ret void
144+
}
145+
117146
define void @cttz(i32 %a, <16 x i32> %va) {
118147
; THRU-LABEL: 'cttz'
119148
; THRU-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %s = call i32 @llvm.cttz.i32(i32 %a, i1 false)

0 commit comments

Comments
 (0)