Skip to content

Commit 4afb264

Browse files
committed
[TTI] Provide a cost for memset_pattern which matches the libcall
The motivation is that differences in unrolling were noticed when trying to swich from the libcall to the intrinsic. Neither cost is a good, well considered cost, but for the moment, let's have them be equal to simplify migration.
1 parent aee4e57 commit 4afb264

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
24082408
CmpInst::ICMP_ULT, CostKind);
24092409
return Cost;
24102410
}
2411+
case Intrinsic::experimental_memset_pattern:
2412+
// This cost is set to match the cost of the memset_pattern16 libcall
2413+
return TTI::TCC_Basic * 4;
24112414
case Intrinsic::abs:
24122415
ISD = ISD::ABS;
24132416
break;

llvm/test/Analysis/CostModel/X86/memset-pattern.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ declare void @memset_pattern16(ptr, ptr, i64)
2626

2727
define void @via_intrinsic(ptr %p) {
2828
; CHECK-LABEL: 'via_intrinsic'
29-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: call void @llvm.experimental.memset.pattern.p0.i16.i64(ptr align 4 %p, i16 2, i64 100, i1 false)
30-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: call void @llvm.experimental.memset.pattern.p0.i32.i64(ptr align 4 %p, i32 2, i64 50, i1 false)
31-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: call void @llvm.experimental.memset.pattern.p0.i64.i64(ptr align 4 %p, i64 2, i64 25, i1 false)
32-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: call void @llvm.experimental.memset.pattern.p0.i128.i64(ptr align 4 %p, i128 2, i64 12, i1 false)
29+
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: call void @llvm.experimental.memset.pattern.p0.i16.i64(ptr align 4 %p, i16 2, i64 100, i1 false)
30+
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: call void @llvm.experimental.memset.pattern.p0.i32.i64(ptr align 4 %p, i32 2, i64 50, i1 false)
31+
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: call void @llvm.experimental.memset.pattern.p0.i64.i64(ptr align 4 %p, i64 2, i64 25, i1 false)
32+
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: call void @llvm.experimental.memset.pattern.p0.i128.i64(ptr align 4 %p, i128 2, i64 12, i1 false)
3333
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
3434
;
3535
call void @llvm.experimental.memset.pattern(ptr align 4 %p, i16 2, i64 100, i1 false)

0 commit comments

Comments
 (0)