Skip to content

Commit f5a11ac

Browse files
committed
Address comments
1 parent 074f53f commit f5a11ac

File tree

4 files changed

+21
-242
lines changed

4 files changed

+21
-242
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,14 +3586,15 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
35863586
Op1Info.getNoProps(), Op2Info.getNoProps());
35873587
// add/cmp/csel/csneg should have similar cost while asr/negs/and should
35883588
// have similar cost.
3589-
if (LT.second.isScalarInteger()) {
3589+
auto VT = TLI->getValueType(DL, Ty);
3590+
if (LT.second.isScalarInteger() && VT.getSizeInBits() <= 64) {
35903591
if (Op2Info.isPowerOf2()) {
35913592
return ISD == ISD::SDIV ? (3 * AddCost + AsrCost)
35923593
: (3 * AsrCost + AddCost);
35933594
} else {
35943595
return MulCost + AsrCost + 2 * AddCost;
35953596
}
3596-
} else {
3597+
} else if (VT.isVector()) {
35973598
InstructionCost UsraCost = 2 * AsrCost;
35983599
if (Op2Info.isPowerOf2()) {
35993600
// Division with scalable types corresponds to native 'asrd'
@@ -3606,9 +3607,7 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
36063607
? (LT.second.getScalarType() == MVT::i64 ? 1 : 2) *
36073608
AsrCost
36083609
: 2 * AddCost);
3609-
} else if (LT.second.is128BitVector() &&
3610-
LT.second.getScalarType() == MVT::i64) {
3611-
auto VT = TLI->getValueType(DL, Ty);
3610+
} else if (LT.second == MVT::v2i64) {
36123611
return VT.getVectorNumElements() *
36133612
getArithmeticInstrCost(Opcode, Ty->getScalarType(), CostKind,
36143613
Op1Info.getNoProps(),

llvm/test/Analysis/CostModel/AArch64/div.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ define void @udiv_uniform() {
287287

288288
define void @sdiv_const() {
289289
; CHECK-LABEL: 'sdiv_const'
290-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = sdiv i128 undef, 7
290+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, 7
291291
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = sdiv i64 undef, 7
292292
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i64 = sdiv <2 x i64> undef, <i64 6, i64 7>
293293
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4i64 = sdiv <4 x i64> undef, <i64 4, i64 5, i64 6, i64 7>
@@ -404,7 +404,7 @@ define void @udiv_const() {
404404

405405
define void @sdiv_uniformconst() {
406406
; CHECK-LABEL: 'sdiv_uniformconst'
407-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = sdiv i128 undef, 7
407+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, 7
408408
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = sdiv i64 undef, 7
409409
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V2i64 = sdiv <2 x i64> undef, splat (i64 7)
410410
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V4i64 = sdiv <4 x i64> undef, splat (i64 7)
@@ -520,7 +520,7 @@ define void @udiv_uniformconst() {
520520

521521
define void @sdiv_constpow2() {
522522
; CHECK-LABEL: 'sdiv_constpow2'
523-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = sdiv i128 undef, 16
523+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, 16
524524
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = sdiv i64 undef, 16
525525
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i64 = sdiv <2 x i64> undef, <i64 8, i64 16>
526526
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4i64 = sdiv <4 x i64> undef, <i64 2, i64 4, i64 8, i64 16>
@@ -636,7 +636,7 @@ define void @udiv_constpow2() {
636636

637637
define void @sdiv_uniformconstpow2() {
638638
; CHECK-LABEL: 'sdiv_uniformconstpow2'
639-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = sdiv i128 undef, 16
639+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, 16
640640
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = sdiv i64 undef, 16
641641
; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %V2i64 = sdiv <2 x i64> undef, splat (i64 16)
642642
; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V4i64 = sdiv <4 x i64> undef, splat (i64 16)
@@ -752,7 +752,7 @@ define void @udiv_uniformconstpow2() {
752752

753753
define void @sdiv_constnegpow2() {
754754
; CHECK-LABEL: 'sdiv_constnegpow2'
755-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = sdiv i128 undef, -16
755+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, -16
756756
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = sdiv i64 undef, -16
757757
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V2i64 = sdiv <2 x i64> undef, <i64 -8, i64 -16>
758758
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V4i64 = sdiv <4 x i64> undef, <i64 -2, i64 -4, i64 -8, i64 -16>
@@ -868,7 +868,7 @@ define void @udiv_constnegpow2() {
868868

869869
define void @sdiv_uniformconstnegpow2() {
870870
; CHECK-LABEL: 'sdiv_uniformconstnegpow2'
871-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = sdiv i128 undef, -16
871+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = sdiv i128 undef, -16
872872
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = sdiv i64 undef, -16
873873
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V2i64 = sdiv <2 x i64> undef, splat (i64 -16)
874874
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V4i64 = sdiv <4 x i64> undef, splat (i64 -16)

llvm/test/Analysis/CostModel/AArch64/rem.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ define void @urem_uniform() {
287287

288288
define void @srem_const() {
289289
; CHECK-LABEL: 'srem_const'
290-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = srem i128 undef, 7
290+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = srem i128 undef, 7
291291
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = srem i64 undef, 7
292292
; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V2i64 = srem <2 x i64> undef, <i64 6, i64 7>
293293
; CHECK-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V4i64 = srem <4 x i64> undef, <i64 4, i64 5, i64 6, i64 7>
@@ -404,7 +404,7 @@ define void @urem_const() {
404404

405405
define void @srem_uniformconst() {
406406
; CHECK-LABEL: 'srem_uniformconst'
407-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = srem i128 undef, 7
407+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = srem i128 undef, 7
408408
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = srem i64 undef, 7
409409
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V2i64 = srem <2 x i64> undef, splat (i64 7)
410410
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V4i64 = srem <4 x i64> undef, splat (i64 7)
@@ -520,7 +520,7 @@ define void @urem_uniformconst() {
520520

521521
define void @srem_constpow2() {
522522
; CHECK-LABEL: 'srem_constpow2'
523-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = srem i128 undef, 16
523+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = srem i128 undef, 16
524524
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = srem i64 undef, 16
525525
; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V2i64 = srem <2 x i64> undef, <i64 8, i64 16>
526526
; CHECK-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V4i64 = srem <4 x i64> undef, <i64 2, i64 4, i64 8, i64 16>
@@ -636,7 +636,7 @@ define void @urem_constpow2() {
636636

637637
define void @srem_uniformconstpow2() {
638638
; CHECK-LABEL: 'srem_uniformconstpow2'
639-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = srem i128 undef, 16
639+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = srem i128 undef, 16
640640
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = srem i64 undef, 16
641641
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V2i64 = srem <2 x i64> undef, splat (i64 16)
642642
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V4i64 = srem <4 x i64> undef, splat (i64 16)
@@ -752,7 +752,7 @@ define void @urem_uniformconstpow2() {
752752

753753
define void @srem_constnegpow2() {
754754
; CHECK-LABEL: 'srem_constnegpow2'
755-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = srem i128 undef, -16
755+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = srem i128 undef, -16
756756
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = srem i64 undef, -16
757757
; CHECK-NEXT: Cost Model: Found an estimated cost of 6 for instruction: %V2i64 = srem <2 x i64> undef, <i64 -8, i64 -16>
758758
; CHECK-NEXT: Cost Model: Found an estimated cost of 12 for instruction: %V4i64 = srem <4 x i64> undef, <i64 -2, i64 -4, i64 -8, i64 -16>
@@ -868,7 +868,7 @@ define void @urem_constnegpow2() {
868868

869869
define void @srem_uniformconstnegpow2() {
870870
; CHECK-LABEL: 'srem_uniformconstnegpow2'
871-
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %I128 = srem i128 undef, -16
871+
; CHECK-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %I128 = srem i128 undef, -16
872872
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %I64 = srem i64 undef, -16
873873
; CHECK-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %V2i64 = srem <2 x i64> undef, splat (i64 -16)
874874
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %V4i64 = srem <4 x i64> undef, splat (i64 -16)

0 commit comments

Comments
 (0)