[PATCH] D109388: [AArch64][CostModel] Use cost of target trunc type when only use of a non-register sized load

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 05:49:24 PDT 2021


samparker added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:1462
                                                 const Instruction *I) {
+  if(I && I->hasOneUse()) {
+    if (const TruncInst *TI = dyn_cast<TruncInst>(*I->user_begin()))
----------------
Looks like you're better off calculating the cost from the trunc, in getCastInstrCost, instead of here. If you really only mean code size cost, but the trunc is probably free for all costs for all legal loads, remember to also check that CostKind == TTI::TCK_CodeSize too.


================
Comment at: llvm/test/Analysis/CostModel/AArch64/load-to-trunc.ll:10
+; CHECK: 'Cost Model Analysis' for function 'loadUnusualIntegerWithTrunc':
+; CHECK: Cost Model: Found an estimated cost of 1 for instruction:
+  %out = load i1228, i1228* %ptr
----------------
Even if the trunc is free, we're still going to pay quite a bit for legalizing the unusual load, if this test is showing the cost of the load then it doesn't make sense.


================
Comment at: llvm/test/Analysis/CostModel/AArch64/load-to-trunc.ll:18
+; CHECK: 'Cost Model Analysis' for function 'loadUnusualInteger':
+; CHECKa load : Cost Model: Found an estimated cost of 32 for instruction:
+  %out = load i1228, i1228* %ptr
----------------
This check doesn't look right.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109388/new/

https://reviews.llvm.org/D109388



More information about the llvm-commits mailing list