Skip to content

Commit 254da5a

Browse files
committed
[CostModel][X86] Add missing costkinds for scalar CTLZ/CTTZ instructions
Baed off worst case llvm-mca numbers for CTLZ/CTTZ(+ZERO_UNDEF) codegen Prep work for #102885
1 parent 27e5f50 commit 254da5a

File tree

13 files changed

+2146
-1274
lines changed

13 files changed

+2146
-1274
lines changed

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4183,37 +4183,37 @@ X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
41834183
{ ISD::FSQRT, MVT::v4f32, { 56, 56, 1, 2 } }, // Pentium III from http://www.agner.org/
41844184
};
41854185
static const CostKindTblEntry BMI64CostTbl[] = { // 64-bit targets
4186-
{ ISD::CTTZ, MVT::i64, { 1 } },
4186+
{ ISD::CTTZ, MVT::i64, { 1, 1, 1, 1 } },
41874187
};
41884188
static const CostKindTblEntry BMI32CostTbl[] = { // 32 or 64-bit targets
4189-
{ ISD::CTTZ, MVT::i32, { 1 } },
4190-
{ ISD::CTTZ, MVT::i16, { 1 } },
4191-
{ ISD::CTTZ, MVT::i8, { 1 } },
4189+
{ ISD::CTTZ, MVT::i32, { 1, 1, 1, 1 } },
4190+
{ ISD::CTTZ, MVT::i16, { 2, 1, 1, 1 } },
4191+
{ ISD::CTTZ, MVT::i8, { 2, 1, 1, 1 } },
41924192
};
41934193
static const CostKindTblEntry LZCNT64CostTbl[] = { // 64-bit targets
4194-
{ ISD::CTLZ, MVT::i64, { 1 } },
4194+
{ ISD::CTLZ, MVT::i64, { 1, 1, 1, 1 } },
41954195
};
41964196
static const CostKindTblEntry LZCNT32CostTbl[] = { // 32 or 64-bit targets
4197-
{ ISD::CTLZ, MVT::i32, { 1 } },
4198-
{ ISD::CTLZ, MVT::i16, { 2 } },
4199-
{ ISD::CTLZ, MVT::i8, { 2 } },
4197+
{ ISD::CTLZ, MVT::i32, { 1, 1, 1, 1 } },
4198+
{ ISD::CTLZ, MVT::i16, { 2, 1, 1, 1 } },
4199+
{ ISD::CTLZ, MVT::i8, { 2, 1, 1, 1 } },
42004200
};
42014201
static const CostKindTblEntry POPCNT64CostTbl[] = { // 64-bit targets
4202-
{ ISD::CTPOP, MVT::i64, { 1, 1, 1, 1 } }, // popcnt
4202+
{ ISD::CTPOP, MVT::i64, { 1, 1, 1, 1 } }, // popcnt
42034203
};
42044204
static const CostKindTblEntry POPCNT32CostTbl[] = { // 32 or 64-bit targets
4205-
{ ISD::CTPOP, MVT::i32, { 1, 1, 1, 1 } }, // popcnt
4206-
{ ISD::CTPOP, MVT::i16, { 1, 1, 2, 2 } }, // popcnt(zext())
4207-
{ ISD::CTPOP, MVT::i8, { 1, 1, 2, 2 } }, // popcnt(zext())
4205+
{ ISD::CTPOP, MVT::i32, { 1, 1, 1, 1 } }, // popcnt
4206+
{ ISD::CTPOP, MVT::i16, { 1, 1, 2, 2 } }, // popcnt(zext())
4207+
{ ISD::CTPOP, MVT::i8, { 1, 1, 2, 2 } }, // popcnt(zext())
42084208
};
42094209
static const CostKindTblEntry X64CostTbl[] = { // 64-bit targets
42104210
{ ISD::ABS, MVT::i64, { 1, 2, 3, 3 } }, // SUB+CMOV
42114211
{ ISD::BITREVERSE, MVT::i64, { 10, 12, 20, 22 } },
42124212
{ ISD::BSWAP, MVT::i64, { 1, 2, 1, 2 } },
4213-
{ ISD::CTLZ, MVT::i64, { 4 } }, // BSR+XOR or BSR+XOR+CMOV
4214-
{ ISD::CTLZ_ZERO_UNDEF, MVT::i64,{ 1, 1, 1, 1 } }, // BSR+XOR
4215-
{ ISD::CTTZ, MVT::i64, { 3 } }, // TEST+BSF+CMOV/BRANCH
4216-
{ ISD::CTTZ_ZERO_UNDEF, MVT::i64,{ 1, 1, 1, 1 } }, // BSR
4213+
{ ISD::CTLZ, MVT::i64, { 3, 2, 6, 6 } }, // BSR+XOR or BSR+XOR+CMOV
4214+
{ ISD::CTLZ_ZERO_UNDEF, MVT::i64,{ 1, 2, 2, 2 } }, // BSR+XOR
4215+
{ ISD::CTTZ, MVT::i64, { 2, 2, 5, 5 } }, // TEST+BSF+CMOV/BRANCH
4216+
{ ISD::CTTZ_ZERO_UNDEF, MVT::i64,{ 1, 2, 1, 2 } }, // BSF
42174217
{ ISD::CTPOP, MVT::i64, { 10, 6, 19, 19 } },
42184218
{ ISD::ROTL, MVT::i64, { 2, 3, 1, 3 } },
42194219
{ ISD::ROTR, MVT::i64, { 2, 3, 1, 3 } },
@@ -4241,18 +4241,18 @@ X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
42414241
{ ISD::BITREVERSE, MVT::i8, { 7, 9, 13, 14 } },
42424242
{ ISD::BSWAP, MVT::i32, { 1, 1, 1, 1 } },
42434243
{ ISD::BSWAP, MVT::i16, { 1, 2, 1, 2 } }, // ROL
4244-
{ ISD::CTLZ, MVT::i32, { 4 } }, // BSR+XOR or BSR+XOR+CMOV
4245-
{ ISD::CTLZ, MVT::i16, { 4 } }, // BSR+XOR or BSR+XOR+CMOV
4246-
{ ISD::CTLZ, MVT::i8, { 4 } }, // BSR+XOR or BSR+XOR+CMOV
4247-
{ ISD::CTLZ_ZERO_UNDEF, MVT::i32,{ 1, 1, 1, 1 } }, // BSR+XOR
4248-
{ ISD::CTLZ_ZERO_UNDEF, MVT::i16,{ 2, 2, 3, 3 } }, // BSR+XOR
4244+
{ ISD::CTLZ, MVT::i32, { 3, 2, 6, 6 } }, // BSR+XOR or BSR+XOR+CMOV
4245+
{ ISD::CTLZ, MVT::i16, { 3, 2, 6, 6 } }, // BSR+XOR or BSR+XOR+CMOV
4246+
{ ISD::CTLZ, MVT::i8, { 3, 2, 7, 7 } }, // BSR+XOR or BSR+XOR+CMOV
4247+
{ ISD::CTLZ_ZERO_UNDEF, MVT::i32,{ 1, 2, 2, 2 } }, // BSR+XOR
4248+
{ ISD::CTLZ_ZERO_UNDEF, MVT::i16,{ 2, 2, 2, 2 } }, // BSR+XOR
42494249
{ ISD::CTLZ_ZERO_UNDEF, MVT::i8, { 2, 2, 3, 3 } }, // BSR+XOR
4250-
{ ISD::CTTZ, MVT::i32, { 3 } }, // TEST+BSF+CMOV/BRANCH
4251-
{ ISD::CTTZ, MVT::i16, { 3 } }, // TEST+BSF+CMOV/BRANCH
4252-
{ ISD::CTTZ, MVT::i8, { 3 } }, // TEST+BSF+CMOV/BRANCH
4253-
{ ISD::CTTZ_ZERO_UNDEF, MVT::i32,{ 1, 1, 1, 1 } }, // BSF
4254-
{ ISD::CTTZ_ZERO_UNDEF, MVT::i16,{ 2, 2, 1, 1 } }, // BSF
4255-
{ ISD::CTTZ_ZERO_UNDEF, MVT::i8, { 2, 2, 1, 1 } }, // BSF
4250+
{ ISD::CTTZ, MVT::i32, { 2, 2, 3, 3 } }, // TEST+BSF+CMOV/BRANCH
4251+
{ ISD::CTTZ, MVT::i16, { 2, 2, 2, 3 } }, // TEST+BSF+CMOV/BRANCH
4252+
{ ISD::CTTZ, MVT::i8, { 2, 2, 2, 3 } }, // TEST+BSF+CMOV/BRANCH
4253+
{ ISD::CTTZ_ZERO_UNDEF, MVT::i32,{ 1, 2, 1, 2 } }, // BSF
4254+
{ ISD::CTTZ_ZERO_UNDEF, MVT::i16,{ 2, 2, 1, 2 } }, // BSF
4255+
{ ISD::CTTZ_ZERO_UNDEF, MVT::i8, { 2, 2, 1, 2 } }, // BSF
42564256
{ ISD::CTPOP, MVT::i32, { 8, 7, 15, 15 } },
42574257
{ ISD::CTPOP, MVT::i16, { 9, 8, 17, 17 } },
42584258
{ ISD::CTPOP, MVT::i8, { 7, 6, 6, 6 } },

llvm/test/Analysis/CostModel/X86/ctlz-codesize.ll

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare i8 @llvm.ctlz.i8(i8, i1)
1717

1818
define i64 @var_ctlz_i64(i64 %a) {
1919
; NOLZCNT-LABEL: 'var_ctlz_i64'
20-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
20+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
2121
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
2222
;
2323
; LZCNT-LABEL: 'var_ctlz_i64'
@@ -29,17 +29,21 @@ define i64 @var_ctlz_i64(i64 %a) {
2929
}
3030

3131
define i64 @var_ctlz_i64u(i64 %a) {
32-
; CHECK-LABEL: 'var_ctlz_i64u'
33-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
34-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
32+
; NOLZCNT-LABEL: 'var_ctlz_i64u'
33+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
34+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
35+
;
36+
; LZCNT-LABEL: 'var_ctlz_i64u'
37+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
38+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
3539
;
3640
%ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 1)
3741
ret i64 %ctlz
3842
}
3943

4044
define i32 @var_ctlz_i32(i32 %a) {
4145
; NOLZCNT-LABEL: 'var_ctlz_i32'
42-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
46+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
4347
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
4448
;
4549
; LZCNT-LABEL: 'var_ctlz_i32'
@@ -51,17 +55,21 @@ define i32 @var_ctlz_i32(i32 %a) {
5155
}
5256

5357
define i32 @var_ctlz_i32u(i32 %a) {
54-
; CHECK-LABEL: 'var_ctlz_i32u'
55-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
56-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
58+
; NOLZCNT-LABEL: 'var_ctlz_i32u'
59+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
60+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
61+
;
62+
; LZCNT-LABEL: 'var_ctlz_i32u'
63+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
64+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
5765
;
5866
%ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 1)
5967
ret i32 %ctlz
6068
}
6169

6270
define i16 @var_ctlz_i16(i16 %a) {
6371
; NOLZCNT-LABEL: 'var_ctlz_i16'
64-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false)
72+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false)
6573
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i16 %ctlz
6674
;
6775
; LZCNT-LABEL: 'var_ctlz_i16'
@@ -74,7 +82,7 @@ define i16 @var_ctlz_i16(i16 %a) {
7482

7583
define i16 @var_ctlz_i16u(i16 %a) {
7684
; NOLZCNT-LABEL: 'var_ctlz_i16u'
77-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 true)
85+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 true)
7886
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i16 %ctlz
7987
;
8088
; LZCNT-LABEL: 'var_ctlz_i16u'
@@ -87,7 +95,7 @@ define i16 @var_ctlz_i16u(i16 %a) {
8795

8896
define i8 @var_ctlz_i8(i8 %a) {
8997
; NOLZCNT-LABEL: 'var_ctlz_i8'
90-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false)
98+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false)
9199
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i8 %ctlz
92100
;
93101
; LZCNT-LABEL: 'var_ctlz_i8'
@@ -919,3 +927,5 @@ define <64 x i8> @var_ctlz_v64i8u(<64 x i8> %a) {
919927
%ctlz = call <64 x i8> @llvm.ctlz.v64i8(<64 x i8> %a, i1 1)
920928
ret <64 x i8> %ctlz
921929
}
930+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
931+
; CHECK: {{.*}}

llvm/test/Analysis/CostModel/X86/ctlz-latency.ll

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ define i64 @var_ctlz_i64(i64 %a) {
2929
}
3030

3131
define i64 @var_ctlz_i64u(i64 %a) {
32-
; CHECK-LABEL: 'var_ctlz_i64u'
33-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
34-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
32+
; NOLZCNT-LABEL: 'var_ctlz_i64u'
33+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
34+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
35+
;
36+
; LZCNT-LABEL: 'var_ctlz_i64u'
37+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
38+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
3539
;
3640
%ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 1)
3741
ret i64 %ctlz
@@ -51,9 +55,13 @@ define i32 @var_ctlz_i32(i32 %a) {
5155
}
5256

5357
define i32 @var_ctlz_i32u(i32 %a) {
54-
; CHECK-LABEL: 'var_ctlz_i32u'
55-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
56-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
58+
; NOLZCNT-LABEL: 'var_ctlz_i32u'
59+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
60+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
61+
;
62+
; LZCNT-LABEL: 'var_ctlz_i32u'
63+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
64+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
5765
;
5866
%ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 1)
5967
ret i32 %ctlz
@@ -935,3 +943,5 @@ define <64 x i8> @var_ctlz_v64i8u(<64 x i8> %a) {
935943
%ctlz = call <64 x i8> @llvm.ctlz.v64i8(<64 x i8> %a, i1 1)
936944
ret <64 x i8> %ctlz
937945
}
946+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
947+
; CHECK: {{.*}}

llvm/test/Analysis/CostModel/X86/ctlz-sizelatency.ll

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare i8 @llvm.ctlz.i8(i8, i1)
1717

1818
define i64 @var_ctlz_i64(i64 %a) {
1919
; NOLZCNT-LABEL: 'var_ctlz_i64'
20-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
20+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
2121
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
2222
;
2323
; LZCNT-LABEL: 'var_ctlz_i64'
@@ -29,17 +29,21 @@ define i64 @var_ctlz_i64(i64 %a) {
2929
}
3030

3131
define i64 @var_ctlz_i64u(i64 %a) {
32-
; CHECK-LABEL: 'var_ctlz_i64u'
33-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
34-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
32+
; NOLZCNT-LABEL: 'var_ctlz_i64u'
33+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
34+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
35+
;
36+
; LZCNT-LABEL: 'var_ctlz_i64u'
37+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 true)
38+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ctlz
3539
;
3640
%ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 1)
3741
ret i64 %ctlz
3842
}
3943

4044
define i32 @var_ctlz_i32(i32 %a) {
4145
; NOLZCNT-LABEL: 'var_ctlz_i32'
42-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
46+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
4347
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
4448
;
4549
; LZCNT-LABEL: 'var_ctlz_i32'
@@ -51,17 +55,21 @@ define i32 @var_ctlz_i32(i32 %a) {
5155
}
5256

5357
define i32 @var_ctlz_i32u(i32 %a) {
54-
; CHECK-LABEL: 'var_ctlz_i32u'
55-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
56-
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
58+
; NOLZCNT-LABEL: 'var_ctlz_i32u'
59+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
60+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
61+
;
62+
; LZCNT-LABEL: 'var_ctlz_i32u'
63+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 true)
64+
; LZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %ctlz
5765
;
5866
%ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 1)
5967
ret i32 %ctlz
6068
}
6169

6270
define i16 @var_ctlz_i16(i16 %a) {
6371
; NOLZCNT-LABEL: 'var_ctlz_i16'
64-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false)
72+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false)
6573
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i16 %ctlz
6674
;
6775
; LZCNT-LABEL: 'var_ctlz_i16'
@@ -74,7 +82,7 @@ define i16 @var_ctlz_i16(i16 %a) {
7482

7583
define i16 @var_ctlz_i16u(i16 %a) {
7684
; NOLZCNT-LABEL: 'var_ctlz_i16u'
77-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 true)
85+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 true)
7886
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i16 %ctlz
7987
;
8088
; LZCNT-LABEL: 'var_ctlz_i16u'
@@ -87,7 +95,7 @@ define i16 @var_ctlz_i16u(i16 %a) {
8795

8896
define i8 @var_ctlz_i8(i8 %a) {
8997
; NOLZCNT-LABEL: 'var_ctlz_i8'
90-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false)
98+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false)
9199
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i8 %ctlz
92100
;
93101
; LZCNT-LABEL: 'var_ctlz_i8'
@@ -951,3 +959,5 @@ define <64 x i8> @var_ctlz_v64i8u(<64 x i8> %a) {
951959
%ctlz = call <64 x i8> @llvm.ctlz.v64i8(<64 x i8> %a, i1 1)
952960
ret <64 x i8> %ctlz
953961
}
962+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
963+
; CHECK: {{.*}}

llvm/test/Analysis/CostModel/X86/ctlz.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare i8 @llvm.ctlz.i8(i8, i1)
1717

1818
define i64 @var_ctlz_i64(i64 %a) {
1919
; NOLZCNT-LABEL: 'var_ctlz_i64'
20-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
20+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 false)
2121
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %ctlz
2222
;
2323
; LZCNT-LABEL: 'var_ctlz_i64'
@@ -43,7 +43,7 @@ define i64 @var_ctlz_i64u(i64 %a) {
4343

4444
define i32 @var_ctlz_i32(i32 %a) {
4545
; NOLZCNT-LABEL: 'var_ctlz_i32'
46-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
46+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 false)
4747
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ctlz
4848
;
4949
; LZCNT-LABEL: 'var_ctlz_i32'
@@ -69,7 +69,7 @@ define i32 @var_ctlz_i32u(i32 %a) {
6969

7070
define i16 @var_ctlz_i16(i16 %a) {
7171
; NOLZCNT-LABEL: 'var_ctlz_i16'
72-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false)
72+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 false)
7373
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %ctlz
7474
;
7575
; LZCNT-LABEL: 'var_ctlz_i16'
@@ -95,7 +95,7 @@ define i16 @var_ctlz_i16u(i16 %a) {
9595

9696
define i8 @var_ctlz_i8(i8 %a) {
9797
; NOLZCNT-LABEL: 'var_ctlz_i8'
98-
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false)
98+
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 false)
9999
; NOLZCNT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %ctlz
100100
;
101101
; LZCNT-LABEL: 'var_ctlz_i8'

0 commit comments

Comments
 (0)