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

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 13:33:34 PDT 2021


dmgreen added a comment.

In general, you can't expect the costmodel to reverse-engineer every optimization that might happen in the llvm pipeline. There are too many to be sensibly captured and the IR needs to be at least somewhat representative of what the backend will see. I don't think there is anything before ISel that will split up a trunc of a load like this though.

Do you plan to do this for all architectures?



================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:1464
+    if (const TruncInst *TI = dyn_cast<TruncInst>(*I->user_begin()))
+      Ty = TI->getDestTy();
+  }
----------------
I don't believe this will be correct for vectors.


================
Comment at: llvm/test/Analysis/CostModel/AArch64/load-to-trunc.ll:8
+; Check that cost is 1 for unusual load to 
+define i32 @loadUnusualIntegerWithTrunc(i1228* %ptr) {
+; CHECK: 'Cost Model Analysis' for function 'loadUnusualIntegerWithTrunc':
----------------
A i128 would show what you mean to here, without being so large. It is also worth adding a few extra sizes, for things like i64 load truncated to i32/i8 etc. They will be much more common.

Also use the update_analysis_test_checks script.


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